Changeset 979 in svn


Ignore:
Timestamp:
2012-07-16T10:41:38+02:00 (3 years ago)
Author:
Xuefer
Message:

closes #2: auto disable on crash

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r978 r979  
    33========
    44 * chg: proto array xcache_clear_cache(int type, [ int id = -1 ]). -1 means all cache splits
     5
     6Ini Settings Changes
     7========
     8 * new: xcache.disable_on_crash = Off
     9
    510ChangeLog
    611========
     12 * closes #2: auto disable caching on crash
    713 * closes #972: warning/error when XCache is loaded incorrectly
    814 * closes #73: warn for improper PHP_FCGI_CHILDREN setting fcgi mode (>=PHP_5_3)
  • trunk/NEWS

    r974 r979  
    33 * improvements
    44 * adds warning for misconfiguration
     5 * auto disable caching on crash
    56
    672.0.1 2012-07-14
  • trunk/mmap.c

    r924 r979  
    4141struct _xc_mmap_shm_t {
    4242    xc_shm_handlers_t *handlers;
     43    zend_bool disabled;
    4344    void *ptr;
    4445    void *ptr_ro;
  • trunk/xc_shm.h

    r393 r979  
    66struct _xc_shm_t {
    77    const xc_shm_handlers_t *handlers;
     8    zend_bool disabled;
    89};
    910#define XC_SHM_IMPL _xc_shm_t
  • trunk/xcache.c

    r978 r979  
    7070static char *xc_mmap_path = NULL;
    7171static char *xc_coredump_dir = NULL;
     72static zend_bool xc_disable_on_crash = 0;
    7273
    7374static xc_hash_t xc_php_hcache = { 0 };
     
    8788static zend_ulong xc_var_size  = 0;
    8889
     90static xc_shm_t *xc_shm = NULL;
    8991static xc_cache_t **xc_php_caches = NULL;
    9092static xc_cache_t **xc_var_caches = NULL;
     
    21552157     || strstr(PG(include_path), "://") != NULL
    21562158#endif
     2159     || xc_shm || xc_shm->disabled
    21572160     ) {
    21582161        TRACE("%s", "cacher not enabled");
     
    23042307}
    23052308/* }}} */
    2306 static xc_shm_t *xc_cache_destroy(xc_cache_t **caches, xc_hash_t *hcache) /* {{{ */
     2309static void xc_cache_destroy(xc_cache_t **caches, xc_hash_t *hcache) /* {{{ */
    23072310{
    23082311    size_t i;
    23092312    xc_cache_t *cache;
    2310     xc_shm_t *shm;
    23112313
    23122314    if (!caches) {
    2313         return NULL;
    2314     }
    2315     shm = NULL;
     2315        return;
     2316    }
     2317
    23162318    for (i = 0; i < hcache->size; i ++) {
    23172319        cache = caches[i];
     
    23262328            cache->mem->handlers->free(cache->mem, cache);
    23272329            */
    2328             shm = cache->shm;
    2329             shm->handlers->memdestroy(cache->mem);
     2330            cache->shm->handlers->memdestroy(cache->mem);
    23302331        }
    23312332    }
    23322333    free(caches);
    2333     return shm;
    23342334}
    23352335/* }}} */
     
    23872387static void xc_destroy() /* {{{ */
    23882388{
    2389     xc_shm_t *shm = NULL;
    2390 
    23912389    if (old_compile_file) {
    23922390        zend_compile_file = old_compile_file;
     
    24002398
    24012399    if (xc_php_caches) {
    2402         shm = xc_cache_destroy(xc_php_caches, &xc_php_hcache);
     2400        xc_cache_destroy(xc_php_caches, &xc_php_hcache);
    24032401        xc_php_caches = NULL;
    24042402    }
    24052403
    24062404    if (xc_var_caches) {
    2407         shm = xc_cache_destroy(xc_var_caches, &xc_var_hcache);
     2405        xc_cache_destroy(xc_var_caches, &xc_var_hcache);
    24082406        xc_var_caches = NULL;
    24092407    }
    24102408
    2411     if (shm) {
    2412         xc_shm_destroy(shm);
     2409    if (xc_shm) {
     2410        xc_shm_destroy(xc_shm);
     2411        xc_shm = NULL;
    24132412    }
    24142413
     
    24182417static int xc_init(int module_number TSRMLS_DC) /* {{{ */
    24192418{
    2420     xc_shm_t *shm;
    24212419    xc_shmsize_t shmsize = ALIGN(xc_php_size) + ALIGN(xc_var_size);
    24222420
    24232421    xc_php_caches = xc_var_caches = NULL;
    2424     shm = NULL;
     2422    xc_shm = NULL;
    24252423
    24262424    if (shmsize < (size_t) xc_php_size || shmsize < (size_t) xc_var_size) {
     
    24302428
    24312429    if (xc_php_size || xc_var_size) {
    2432         CHECK(shm = xc_shm_init(xc_shm_scheme, shmsize, xc_readonly_protection, xc_mmap_path, NULL), "Cannot create shm");
    2433         if (!shm->handlers->can_readonly(shm)) {
     2430        CHECK(xc_shm = xc_shm_init(xc_shm_scheme, shmsize, xc_readonly_protection, xc_mmap_path, NULL), "Cannot create shm");
     2431        if (!xc_shm->handlers->can_readonly(xc_shm)) {
    24342432            xc_readonly_protection = 0;
    24352433        }
     
    24392437            zend_compile_file = xc_compile_file;
    24402438
    2441             CHECK(xc_php_caches = xc_cache_init(shm, &xc_php_hcache, &xc_php_hentry, &xc_php_hentry, xc_php_size), "failed init opcode cache");
     2439            CHECK(xc_php_caches = xc_cache_init(xc_shm, &xc_php_hcache, &xc_php_hentry, &xc_php_hentry, xc_php_size), "failed init opcode cache");
    24422440        }
    24432441
    24442442        if (xc_var_size) {
    2445             CHECK(xc_var_caches = xc_cache_init(shm, &xc_var_hcache, &xc_var_hentry, NULL, xc_var_size), "failed init variable cache");
     2443            CHECK(xc_var_caches = xc_cache_init(xc_shm, &xc_var_hcache, &xc_var_hentry, NULL, xc_var_size), "failed init variable cache");
    24462444        }
    24472445    }
     
    24532451        /* shm destroied in xc_destroy() */
    24542452    }
    2455     else if (shm) {
     2453    else if (xc_shm) {
    24562454        xc_destroy();
    2457         xc_shm_destroy(shm);
     2455        xc_shm_destroy(xc_shm);
     2456        xc_shm = NULL;
    24582457    }
    24592458    return 0;
     
    25192518static void xc_request_shutdown(TSRMLS_D) /* {{{ */
    25202519{
    2521     xc_entry_unholds(TSRMLS_C);
     2520    if (xc_shm && !xc_shm->disabled) {
     2521        xc_entry_unholds(TSRMLS_C);
     2522        xc_gc_expires_php(TSRMLS_C);
     2523        xc_gc_expires_var(TSRMLS_C);
     2524        xc_gc_deletes(TSRMLS_C);
     2525    }
    25222526#ifdef ZEND_ENGINE_2
    25232527    zend_llist_destroy(&XG(gc_op_arrays));
    25242528#endif
    2525     xc_gc_expires_php(TSRMLS_C);
    2526     xc_gc_expires_var(TSRMLS_C);
    2527     xc_gc_deletes(TSRMLS_C);
    25282529#ifdef HAVE_XCACHE_COVERAGER
    25292530    xc_coverager_request_shutdown(TSRMLS_C);
     
    27092710    xcache_admin_auth_check(TSRMLS_C);
    27102711
    2711     if (!xc_initized) {
     2712    if (!xc_initized || !xc_shm || xc_shm->disabled) {
    27122713        RETURN_NULL();
    27132714    }
     
    28672868    zval *name;
    28682869
    2869     if (!xc_var_caches) {
     2870    if (!xc_var_caches || !xc_shm || xc_shm->disabled) {
    28702871        VAR_DISABLED_WARNING();
    28712872        RETURN_NULL();
     
    29012902    zval *value;
    29022903
    2903     if (!xc_var_caches) {
     2904    if (!xc_var_caches || !xc_shm || xc_shm->disabled) {
    29042905        VAR_DISABLED_WARNING();
    29052906        RETURN_NULL();
     
    29432944    zval *name;
    29442945
    2945     if (!xc_var_caches) {
     2946    if (!xc_var_caches || !xc_shm || xc_shm->disabled) {
    29462947        VAR_DISABLED_WARNING();
    29472948        RETURN_FALSE;
     
    29772978    zval *name;
    29782979
    2979     if (!xc_var_caches) {
     2980    if (!xc_var_caches || !xc_shm || xc_shm->disabled) {
    29802981        VAR_DISABLED_WARNING();
    29812982        RETURN_FALSE;
     
    30073008    int i, iend;
    30083009
    3009     if (!xc_var_caches) {
     3010    if (!xc_var_caches || !xc_shm || xc_shm->disabled) {
    30103011        VAR_DISABLED_WARNING();
    30113012        RETURN_FALSE;
     
    30433044    zval oldzval;
    30443045
    3045     if (!xc_var_caches) {
     3046    if (!xc_var_caches || !xc_shm || xc_shm->disabled) {
    30463047        VAR_DISABLED_WARNING();
    30473048        RETURN_NULL();
     
    35543555        }
    35553556    }
     3557    if (xc_disable_on_crash) {
     3558        xc_disable_on_crash = 0;
     3559        if (xc_shm) {
     3560            xc_shm->disabled = 1;
     3561        }
     3562    }
    35563563    raise(sig);
    35573564}
     
    36103617    PHP_INI_ENTRY1     ("xcache.mmap_path",     DEFAULT_PATH, PHP_INI_SYSTEM, xc_OnUpdateString,   &xc_mmap_path)
    36113618    PHP_INI_ENTRY1     ("xcache.coredump_directory",      "", PHP_INI_SYSTEM, xc_OnUpdateString,   &xc_coredump_dir)
     3619    PHP_INI_ENTRY1     ("xcache.disable_on_crash",       "0", PHP_INI_SYSTEM, xc_OnUpdateBool,     &xc_disable_on_crash)
    36123620    PHP_INI_ENTRY1     ("xcache.test",                   "0", PHP_INI_SYSTEM, xc_OnUpdateBool,     &xc_test)
    36133621    PHP_INI_ENTRY1     ("xcache.readonly_protection",    "0", PHP_INI_SYSTEM, xc_OnUpdateBool,     &xc_readonly_protection)
  • trunk/xcache.ini

    r927 r979  
    5858; make sure it's writable by php (open_basedir is not checked)
    5959xcache.coredump_directory =   ""
     60; disable cache after crash until restart. (non-Win32 only)
     61xcache.disable_on_crash =    Off
    6062
    6163; enable experimental documented features for each release if available
Note: See TracChangeset for help on using the changeset viewer.