Changeset 903


Ignore:
Timestamp:
2012-06-11T09:25:22+02:00 (3 years ago)
Author:
moo
Message:

fixed #281: changing zend_error may left unclean set up when timeout occur; zend_error is not thread local

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/utils.c

    r875 r903  
    2727    } while(0) 
    2828#endif 
     29 
     30static void (*old_zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) = NULL; 
     31static void call_old_zend_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, ...) /* {{{ */ 
     32{ 
     33    va_list args; 
     34    va_start(args, format); 
     35    old_zend_error_cb(type, error_filename, error_lineno, format, args); 
     36} 
     37/* }}} */ 
     38 
    2939xc_compile_result_t *xc_compile_result_init(xc_compile_result_t *cr, /* {{{ */ 
    3040        zend_op_array *op_array, 
     
    587597 
    588598    sandbox = (xc_sandbox_t *) XG(sandbox); 
    589     assert(sandbox != NULL); 
     599    if (!sandbox) { 
     600        old_zend_error_cb(type, error_filename, error_lineno, format, args); 
     601        return; 
     602    } 
     603 
    590604    switch (type) { 
    591605#ifdef E_STRICT 
     
    614628        /* give up, and user handler is not supported in this case */ 
    615629        zend_uint i; 
    616         zend_uint orig_lineno = CG(zend_lineno); 
    617         zend_error_cb = sandbox->orig_zend_error_cb; 
     630        zend_uint old_lineno = CG(zend_lineno); 
    618631 
    619632        for (i = 0; i < sandbox->compilererror_cnt; i ++) { 
    620633            compilererror = &sandbox->compilererrors[i]; 
    621634            CG(zend_lineno) = compilererror->lineno; 
    622             zend_error(compilererror->type, "%s", compilererror->error); 
    623         } 
    624         CG(zend_lineno) = orig_lineno; 
    625         sandbox->compilererror_cnt = 0; 
    626  
    627         sandbox->orig_zend_error_cb(type, error_filename, error_lineno, format, args); 
     635            call_old_zend_error_cb(compilererror->type, error_filename, error_lineno, "%s", compilererror->error); 
     636            efree(compilererror->error); 
     637        } 
     638        if (sandbox->compilererrors) { 
     639            efree(sandbox->compilererrors); 
     640            sandbox->compilererrors = NULL; 
     641        } 
     642        sandbox->compilererror_cnt  = 0; 
     643        sandbox->compilererror_size = 0; 
     644 
     645        CG(zend_lineno) = old_lineno; 
     646        old_zend_error_cb(type, error_filename, error_lineno, format, args); 
    628647        break; 
    629648    } 
     
    791810    sandbox->compilererror_cnt  = 0; 
    792811    sandbox->compilererror_size = 0; 
    793     sandbox->orig_zend_error_cb = zend_error_cb; 
    794     zend_error_cb = xc_sandbox_error_cb; 
    795812#endif 
    796813 
     
    892909#ifdef XCACHE_ERROR_CACHING 
    893910    EG(user_error_handler_error_reporting) = sandbox->orig_user_error_handler_error_reporting; 
    894     zend_error_cb = sandbox->orig_zend_error_cb; 
    895911#endif 
    896912 
     
    10161032 
    10171033#endif 
     1034 
     1035/* init/destroy */ 
     1036int xc_util_init(int module_number TSRMLS_DC) /* {{{ */ 
     1037{ 
     1038#ifdef XCACHE_ERROR_CACHING 
     1039    old_zend_error_cb = zend_error_cb; 
     1040    zend_error_cb = xc_sandbox_error_cb; 
     1041#endif 
     1042 
     1043    return SUCCESS; 
     1044} 
     1045/* }}} */ 
     1046void xc_util_destroy() /* {{{ */ 
     1047{ 
     1048#ifdef XCACHE_ERROR_CACHING 
     1049    if (zend_error_cb == xc_sandbox_error_cb) { 
     1050        zend_error_cb = old_zend_error_cb; 
     1051    } 
     1052#endif 
     1053} 
     1054/* }}} */ 
     1055 
  • trunk/utils.h

    r860 r903  
    4040#endif /* XCACHE_DEBUG */ 
    4141#include <assert.h> 
     42 
     43int xc_util_init(int module_number TSRMLS_DC); 
     44void xc_util_destroy(); 
    4245 
    4346typedef struct { 
     
    104107#ifdef XCACHE_ERROR_CACHING 
    105108    int orig_user_error_handler_error_reporting; 
    106     void (*orig_zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args); 
    107109    zend_uint compilererror_cnt; 
    108110    zend_uint compilererror_size; 
  • trunk/xcache.c

    r900 r903  
    37353735    } 
    37363736 
     3737    xc_util_init(module_number TSRMLS_CC); 
    37373738#ifdef HAVE_XCACHE_COVERAGER 
    37383739    xc_coverager_init(module_number TSRMLS_CC); 
     
    37633764    xc_coverager_destroy(); 
    37643765#endif 
     3766    xc_util_destroy(); 
    37653767 
    37663768    if (xc_coredump_dir && xc_coredump_dir[0]) { 
Note: See TracChangeset for help on using the changeset viewer.