Changeset 1051 in svn for trunk/xcache.h


Ignore:
Timestamp:
2012-07-26T05:47:52+02:00 (3 years ago)
Author:
Xuefer
Message:

refactor: move more cache stuffs to mod_cacher

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xcache.h

    r1040 r1051  
    1010#define XCACHE_WIKI_URL   XCACHE_URL "/wiki"
    1111
    12 #include <php.h>
     12#include "php.h"
     13
     14#if defined(E_STRICT) || defined(E_DEPRECATED)
     15#define XCACHE_ERROR_CACHING
     16#endif
    1317
    1418#ifdef HAVE_CONFIG_H
     
    1923#include "xcache/xc_compatibility.h"
    2024
    21 #define ECALLOC_N(x, n) ((x) = ecalloc(n, sizeof((x)[0])))
    22 #define ECALLOC_ONE(x) ECALLOC_N(x, 1)
    23 
    24 typedef ulong xc_hash_value_t;
    25 typedef struct {
    26     size_t bits;
    27     size_t size;
    28     xc_hash_value_t mask;
    29 } xc_hash_t;
    30 
    31 typedef zend_op_array *(zend_compile_file_t)(zend_file_handle *h, int type TSRMLS_DC);
    32 
    33 typedef struct _xc_entry_t xc_entry_t;
    34 typedef struct _xc_entry_data_php_t xc_entry_data_php_t;
    35 /* {{{ xc_cache_t */
    36 typedef struct {
    37     int cacheid;
    38     xc_hash_t  *hcache; /* hash to cacheid */
    39 
    40     time_t     compiling;
    41     zend_ulong updates;
    42     zend_ulong hits;
    43     zend_ulong clogs;
    44     zend_ulong ooms;
    45     zend_ulong errors;
    46     xc_lock_t  *lck;
    47     xc_shm_t   *shm; /* which shm contains us */
    48     xc_mem_t   *mem; /* which mem contains us */
    49 
    50     xc_entry_t **entries;
    51     int entries_count;
    52     xc_entry_data_php_t **phps;
    53     int phps_count;
    54     xc_entry_t *deletes;
    55     int deletes_count;
    56     xc_hash_t  *hentry; /* hash settings to entry */
    57     xc_hash_t  *hphp;   /* hash settings to php */
    58 
    59     time_t     last_gc_deletes;
    60     time_t     last_gc_expires;
    61 
    62     time_t     hits_by_hour_cur_time;
    63     zend_uint  hits_by_hour_cur_slot;
    64     zend_ulong hits_by_hour[24];
    65     time_t     hits_by_second_cur_time;
    66     zend_uint  hits_by_second_cur_slot;
    67     zend_ulong hits_by_second[5];
    68 } xc_cache_t;
    69 /* }}} */
    70 /* {{{ xc_op_array_info_detail_t */
    71 typedef struct {
    72     zend_uint index;
    73     zend_uint info;
    74 } xc_op_array_info_detail_t;
    75 /* }}} */
    76 /* {{{ xc_op_array_info_t */
    77 typedef struct {
    78 #ifdef ZEND_ENGINE_2_4
    79     zend_uint literalinfo_cnt;
    80     xc_op_array_info_detail_t *literalinfos;
    81 #else
    82     zend_uint oplineinfo_cnt;
    83     xc_op_array_info_detail_t *oplineinfos;
    84 #endif
    85 } xc_op_array_info_t;
    86 /* }}} */
    87 /* {{{ xc_classinfo_t */
    88 typedef struct {
    89 #ifdef IS_UNICODE
    90     zend_uchar   type;
    91 #endif
    92     const24_zstr key;
    93     zend_uint    key_size;
    94     ulong        h;
    95     zend_uint  methodinfo_cnt;
    96     xc_op_array_info_t *methodinfos;
    97     xc_cest_t    cest;
    98 #ifndef ZEND_COMPILE_DELAYED_BINDING
    99     int          oplineno;
    100 #endif
    101 } xc_classinfo_t;
    102 /* }}} */
    103 #ifdef HAVE_XCACHE_CONSTANT
    104 /* {{{ xc_constinfo_t */
    105 typedef struct {
    106 #ifdef IS_UNICODE
    107     zend_uchar    type;
    108 #endif
    109     const24_zstr  key;
    110     zend_uint     key_size;
    111     ulong         h;
    112     zend_constant constant;
    113 } xc_constinfo_t;
    114 /* }}} */
    115 #endif
    116 /* {{{ xc_funcinfo_t */
    117 typedef struct {
    118 #ifdef IS_UNICODE
    119     zend_uchar     type;
    120 #endif
    121     const24_zstr   key;
    122     zend_uint      key_size;
    123     ulong          h;
    124     xc_op_array_info_t op_array_info;
    125     zend_function func;
    126 } xc_funcinfo_t;
    127 /* }}} */
    128 #ifdef ZEND_ENGINE_2_1
    129 /* {{{ xc_autoglobal_t */
    130 typedef struct {
    131 #ifdef IS_UNICODE
    132     zend_uchar   type;
    133 #endif
    134     const24_zstr key;
    135     zend_uint    key_len;
    136     ulong        h;
    137 } xc_autoglobal_t;
    138 /* }}} */
    139 #endif
    140 typedef struct {
    141     char digest[16];
    142 } xc_md5sum_t;
    143 /* {{{ xc_compilererror_t */
    144 typedef struct {
    145     int type;
    146     uint lineno;
    147     int error_len;
    148     char *error;
    149 } xc_compilererror_t;
    150 /* }}} */
    151 /* {{{ xc_entry_data_php_t */
    152 struct _xc_entry_data_php_t {
    153     xc_entry_data_php_t *next;
    154     xc_hash_value_t      hvalue;
    155 
    156     xc_md5sum_t md5;        /* md5sum of the source */
    157     zend_ulong  refcount;   /* count of entries referencing to this data */
    158 
    159     zend_ulong hits;        /* hits of this php */
    160     size_t     size;
    161 
    162     xc_op_array_info_t op_array_info;
    163     zend_op_array *op_array;
    164 
    165 #ifdef HAVE_XCACHE_CONSTANT
    166     zend_uint constinfo_cnt;
    167     xc_constinfo_t *constinfos;
    168 #endif
    169 
    170     zend_uint funcinfo_cnt;
    171     xc_funcinfo_t *funcinfos;
    172 
    173     zend_uint classinfo_cnt;
    174     xc_classinfo_t *classinfos;
    175 #ifndef ZEND_COMPILE_DELAYED_BINDING
    176     zend_bool have_early_binding;
    177 #endif
    178 
    179 #ifdef ZEND_ENGINE_2_1
    180     zend_uint autoglobal_cnt;
    181     xc_autoglobal_t *autoglobals;
    182 #endif
    183 
    184 #ifdef E_STRICT
    185     zend_uint compilererror_cnt;
    186     xc_compilererror_t *compilererrors;
    187 #endif
    188 
    189     zend_bool  have_references;
    190 };
    191 /* }}} */
    192 typedef zvalue_value xc_entry_name_t;
    193 /* {{{ xc_entry_t */
    194 struct _xc_entry_t {
    195     xc_entry_t *next;
    196 
    197     size_t     size;
    198     time_t     ctime;           /* creation ctime of this entry */
    199     time_t     atime;           /*   access atime of this entry */
    200     time_t     dtime;           /*  deletion time of this entry */
    201     zend_ulong hits;
    202     zend_ulong ttl;
    203 
    204     xc_entry_name_t name;
    205 };
    206 
    207 typedef struct {
    208     xc_entry_t entry;
    209     xc_entry_data_php_t *php;
    210 
    211     zend_ulong refcount;    /* count of php instances holding this entry */
    212     time_t file_mtime;
    213     size_t file_size;
    214     int file_device;
    215     int file_inode;
    216 
    217     int    filepath_len;
    218     ZEND_24(NOTHING, const) char *filepath;
    219     int    dirpath_len;
    220     char  *dirpath;
    221 #ifdef IS_UNICODE
    222     int    ufilepath_len;
    223     UChar *ufilepath;
    224     int    udirpath_len;
    225     UChar *udirpath;
    226 #endif
    227 } xc_entry_php_t;
    228 
    229 typedef struct {
    230     xc_entry_t entry;
    231 #ifdef IS_UNICODE
    232     zend_uchar name_type;
    233 #endif
    234     zval      *value;
    235     zend_bool  have_references;
    236 } xc_entry_var_t;
    237 /* }}} */
    238 typedef struct xc_entry_hash_t { /* {{{ */
    239     xc_hash_value_t cacheid;
    240     xc_hash_value_t entryslotid;
    241 } xc_entry_hash_t;
    242 /* }}} */
    243 
    24425extern zend_module_entry xcache_module_entry;
    24526#define phpext_xcache_ptr &xcache_module_entry
    246 
    247 int xc_is_rw(const void *p);
    248 int xc_is_ro(const void *p);
    249 int xc_is_shm(const void *p);
    250 /* {{{ xc_gc_op_array_t */
    251 typedef struct {
    252 #ifdef ZEND_ENGINE_2
    253     zend_uint num_args;
    254     zend_arg_info *arg_info;
    255 #endif
    256     zend_op *opcodes;
    257 } xc_gc_op_array_t;
    258 /* }}} */
    259 void xc_gc_add_op_array(xc_gc_op_array_t *gc_op_array TSRMLS_DC);
    260 void xc_fix_op_array_info(const xc_entry_php_t *xce, const xc_entry_data_php_t *php, zend_op_array *op_array, int shallow_copy, const xc_op_array_info_t *op_array_info TSRMLS_DC);
    26127
    26228extern zend_bool xc_test;
Note: See TracChangeset for help on using the changeset viewer.