php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #52144
Patch tracing_modified_functions_classes.patch revision 2012-11-08 14:32 UTC by laruence@php.net
Patch bug52144_new.patch revision 2012-11-07 10:58 UTC by laruence@php.net
revision 2012-11-07 07:03 UTC by laruence@php.net
Patch autofilter_missing_funcs.patch revision 2012-11-03 14:59 UTC by gopalv@php.net
Patch auto_filter_on_missing_lambdas.patch revision 2012-11-02 12:18 UTC by gopalv@php.net
Patch bug52144.patch revision 2012-11-02 04:32 UTC by laruence@php.net
revision 2012-11-01 03:10 UTC by laruence@php.net

Patch bug52144_new.patch for APC Bug #52144

Patch version 2012-11-07 10:58 UTC

Return to Bug #52144 | Download this patch
This patch is obsolete

Obsoleted by patches:

This patch renders other patches obsolete

Obsolete patches:

Patch Revisions: 2012-11-07 10:58 UTC | 2012-11-07 07:03 UTC

Developer: laruence@php.net



  Index: apc_main.c
  ===================================================================
  --- apc_main.c	(revision 328266)
  +++ apc_main.c	(working copy)
 @@ -361,15 +361,56 @@
 @@ -361,15 +361,58 @@
   }
   /* }}} */
   
 +/* {{{ void apc_hook_func_table_dtor(void *pDest) */
  +void apc_hook_func_table_dtor(void *pDest) {
  +    zend_function *func = (zend_function *)pDest;
  +    zend_hash_next_index_insert(APCG(compiler_hook_func_table), func->common.function_name, strlen(func->common.function_name) + 1, NULL);
  +    return zend_function_dtor(pDest);
  +}
 +/* }}} */
  +
 +/* {{{ void apc_hook_class_table_dtor(void *pDest) */
  +void apc_hook_class_table_dtor(void *pDest) {
  +    /* not implemented yet */
  +    return destroy_zend_class(pDest);
  +}
 +/* }}} */
  +
   /* {{{ apc_compile_cache_entry  */
   zend_bool apc_compile_cache_entry(apc_cache_key_t *key, zend_file_handle* h, int type, time_t t, zend_op_array** op_array, apc_cache_entry_t** cache_entry TSRMLS_DC) {
  -    int num_functions, num_classes;
Line 26 (now 30), was 12 lines, now 10 lines

       apc_class_t* alloc_classes;
       char *path;
       apc_context_t ctxt;
  +    HashTable *old_hook_class_table = NULL, *old_hook_func_table = NULL;
 +    HashTable *target_class_table = CG(class_table);
 +    HashTable *target_func_table = CG(function_table);
 +    target_func_table->pDestructor = apc_hook_func_table_dtor;
 +    target_class_table->pDestructor = apc_hook_class_table_dtor;
 +    CG(class_table)->pDestructor = apc_hook_class_table_dtor;
 +    CG(function_table)->pDestructor = apc_hook_func_table_dtor;
   
  +#define UNLOAD_COMPILER_TABLES_HOOKER() \
  +    do { \
  +        zend_hash_destroy(APCG(compiler_hook_func_table)); \


  +        zend_hash_destroy(APCG(compiler_hook_class_table)); \
  +        FREE_HASHTABLE(APCG(compiler_hook_class_table));  \
  +        APCG(compiler_hook_func_table) = old_hook_func_table; \
  +        APCG(compiler_hook_class_table) = old_hook_class_table; \
 +        target_class_table->pDestructor = ZEND_CLASS_DTOR; \
 +        target_func_table->pDestructor = ZEND_FUNCTION_DTOR; \
 +        CG(class_table)->pDestructor = ZEND_CLASS_DTOR; \
 +        CG(function_table)->pDestructor = ZEND_FUNCTION_DTOR; \
  +    } while (0);
  +
  +    if (APCG(compiler_hook_func_table)) {
  +        old_hook_func_table = APCG(compiler_hook_func_table);


  +
       /* remember how many functions and classes existed before compilation */
       num_functions = zend_hash_num_elements(CG(function_table));
       num_classes   = zend_hash_num_elements(CG(class_table));
 @@ -379,12 +420,14 @@
 @@ -379,12 +422,14 @@
        * a failure.  We should not return prior to this line.  */
       *op_array = old_compile_file(h, type TSRMLS_CC);
       if (*op_array == NULL) {
  +        UNLOAD_COMPILER_TABLES_HOOKER();


  +        UNLOAD_COMPILER_TABLES_HOOKER();
           apc_warning("Unable to allocate memory for pool." TSRMLS_CC);
           return FAILURE;
       }
 @@ -429,6 +472,15 @@
 @@ -429,6 +474,15 @@
           goto freepool;
       }
   
  +    if ((modified_functions = zend_hash_num_elements(APCG(compiler_hook_func_table)))) {


  +
       path = h->opened_path;
       if(!path && key->type == APC_CACHE_KEY_FPFILE) path = (char*)key->data.fpfile.fullpath;
       if(!path) path=h->filename;
 @@ -438,10 +490,12 @@
 @@ -438,10 +492,12 @@
       if(!(*cache_entry = apc_cache_make_file_entry(path, alloc_op_array, alloc_functions, alloc_classes, &ctxt TSRMLS_CC))) {
           goto freepool;
       }
  -
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 04 14:01:28 2024 UTC