-
Notifications
You must be signed in to change notification settings - Fork 1
/
php_wincache.h
150 lines (136 loc) · 9.48 KB
/
php_wincache.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
+----------------------------------------------------------------------------------------------+
| Windows Cache for PHP |
+----------------------------------------------------------------------------------------------+
| Copyright (c) 2009, Microsoft Corporation. All rights reserved. |
| |
| Redistribution and use in source and binary forms, with or without modification, are |
| permitted provided that the following conditions are met: |
| - Redistributions of source code must retain the above copyright notice, this list of |
| conditions and the following disclaimer. |
| - Redistributions in binary form must reproduce the above copyright notice, this list of |
| conditions and the following disclaimer in the documentation and/or other materials provided |
| with the distribution. |
| - Neither the name of the Microsoft Corporation nor the names of its contributors may be |
| used to endorse or promote products derived from this software without specific prior written|
| permission. |
| |
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS |
| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE|
| GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| OF THE POSSIBILITY OF SUCH DAMAGE. |
+----------------------------------------------------------------------------------------------+
| Module: php_wincache.h |
+----------------------------------------------------------------------------------------------+
| Author: Kanwaljeet Singla <[email protected]> |
| Updated: Eric Stenson <[email protected]> |
+----------------------------------------------------------------------------------------------+
*/
#ifndef _PHP_WINCACHE_H_
#define _PHP_WINCACHE_H_
extern zend_module_entry wincache_module_entry;
#define phpext_wincache_ptr &wincache_module_entry
/* For static builds we need all the headers as this */
/* file is included in main/internal_functions.c */
#ifndef COMPILE_DL_WINCACHE
#include "precomp.h"
#endif
typedef struct wclock_context wclock_context;
struct wclock_context
{
lock_context * lockobj; /* Internal lock context for this wclock */
unsigned int tcreate; /* Tick count when this was created */
unsigned int tuse; /* Tick count when this was last used */
};
/* Module globals */
ZEND_BEGIN_MODULE_GLOBALS(wincache)
aplist_context * lfcache; /* Shared memory for fcache filelist */
zvcache_context * zvucache; /* User controlled user cache */
zvcache_context * zvscache; /* Zval cache used to store session data */
HashTable * phscache; /* Hashtable for session caches for modified savepaths */
unsigned int numfiles; /* Configured number of files to handle */
unsigned int fcchkfreq; /* File change check frequency in seconds */
unsigned int ttlmax; /* Seconds a cache entry can stay dormant */
/* Pointer to the original rmdir function */
zif_handler orig_rmdir;
/* Pointer to the original file_exists function */
zif_handler orig_file_exists;
/* Pointer to the original file_get_contents function */
zif_handler orig_file_get_contents;
/* Pointer to the original filesize function */
zif_handler orig_filesize;
/* Pointer to the original is_dir function */
zif_handler orig_is_dir;
/* Pointer to the original is_file function */
zif_handler orig_is_file;
/* Pointer to the original is_readable function */
zif_handler orig_is_readable;
/* Pointer to the original is_writable function */
zif_handler orig_is_writable;
/* Pointer to the original is_writeable function */
zif_handler orig_is_writeable;
/* Pointer to the original readfile function */
zif_handler orig_readfile;
/* Pointer to the original realpath function */
zif_handler orig_realpath;
/* Pointer to the original unlink function */
zif_handler orig_unlink;
/* Pointer to the original rename function */
zif_handler orig_rename;
zend_bool enablecli; /* Enable wincache for command line sapi */
zend_bool fcenabled; /* File cache enabled or disabled */
unsigned int fcachesize; /* File cache size in MBs */
unsigned int maxfilesize; /* Max file size (kb) allowed in fcache */
zend_bool ucenabled; /* User cache enabled or disabled */
unsigned int ucachesize; /* User cache size in MBs */
unsigned int scachesize; /* Session cache size in MBs */
unsigned int debuglevel; /* Debug dump level (0/101/201/301/401/501) */
char * ignorelist; /* Pipe-separated list of files to ignore */
char * fcefilter; /* Comma-separated sitelist having fcenabled toggled */
char * namesalt; /* Salt to use in all the names */
zend_bool fcndetect; /* File change notication detection enabled */
zend_bool localheap; /* Local heap is enabled or disabled */
HashTable * wclocks; /* Locks created using wincache_lock call */
HashTable * zvcopied; /* Copied zvals to make refcounting work */
unsigned int lasterror; /* Last error value */
unsigned int uclasterror; /* Last error value encountered by user cache */
unsigned int parentpid; /* Parent process identifier */
filemap_global_context * fmapgdata; /* Global data for filemap */
zend_llist * errmsglist; /* List of errors generated by PHP */
zend_ini_entry * inifce; /* fcenabled ini_entry in ini_directives */
zend_ini_entry * inisavepath; /* save_path ini_entry in ini_directives */
unsigned char dofctoggle; /* Do toggle of fcenabled due to filter settigns */
/* Enable wrapper functions around standard PHP functions */
zend_bool reroute_enabled;
const char * apppoolid; /* The application id. */
char * filemapdir; /* Directory where temp filemap files should be created */
ZEND_END_MODULE_GLOBALS(wincache)
ZEND_EXTERN_MODULE_GLOBALS(wincache)
#ifdef ZTS
#define WCG(v) ZEND_TSRMG(wincache_globals_id, zend_wincache_globals *, v)
# ifdef COMPILE_DL_WINCACHE
ZEND_TSRMLS_CACHE_EXTERN();
# endif
#else
#define WCG(v) (wincache_globals.v)
#endif
/* Add in override for the HASH RESET, 7.3 SSE2 optmisations crash extension */
# define WC_HT_HASH_RESET(ht) \
memset(&HT_HASH(ht, (ht)->nTableMask), HT_INVALID_IDX, HT_HASH_SIZE((ht)->nTableMask))
typedef zend_string *(*fn_zend_resolve_path)(const char *filename, int filename_len);
typedef int (*fn_zend_stream_open_function)(const char * filename, zend_file_handle *handle);
typedef zend_op_array * (*fn_zend_compile_file)(zend_file_handle *, int);
typedef void (*fn_zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
fn_zend_resolve_path original_resolve_path;
fn_zend_stream_open_function original_stream_open_function;
extern zend_string * wincache_resolve_path(const char * filename, int filename_len);
extern int wincache_stream_open_function(const char * filename, zend_file_handle * file_handle);
extern void wincache_intercept_functions_init();
extern void wincache_intercept_functions_shutdown();
extern void wincache_save_orig_functions();
#endif /* _PHP_WINCACHE_H_ */