Changeset 17

Show
Ignore:
Timestamp:
12/17/04 23:42:34 (4 years ago)
Author:
everaldo_canuto
Message:

Segv74 patchs for PHP5. New version 0.9.1

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • eaccelerator/trunk/eaccelerator.c

    r12 r17  
    2424   +----------------------------------------------------------------------+ 
    2525   | Author(s): Dmitry Stogov <mmcache@turckware.ru>                      | 
     26   |            Seung Woo <segv@sayclub.com>                              | 
     27   |            Everaldo Canuto <everaldo_canuto@yahoo.com.br>            | 
    2628   +----------------------------------------------------------------------+ 
    2729   $Id$ 
     
    163165#ifdef ZEND_ENGINE_2 
    164166  zend_uint num_args; 
     167  zend_uint required_num_args; 
    165168  zend_arg_info *arg_info; 
    166169  zend_bool pass_rest_by_reference; 
     
    169172#endif 
    170173  char *function_name; 
     174  char *function_name_lc; 
    171175#ifdef ZEND_ENGINE_2 
    172176  char* scope_name; 
     
    197201  char type; 
    198202  char *name; 
     203  char *name_lc; 
    199204  uint name_length; 
    200205  char *parent; 
     
    207212  HashTable constants_table; 
    208213  zend_uint num_interfaces; 
    209  
     214  char **interfaces; 
     215  zend_class_iterator_funcs iterator_funcs; 
     216 
     217  zend_object_value (*create_object)(zend_class_entry *class_type TSRMLS_DC); 
     218  zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object TSRMLS_DC); 
     219  int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type TSRMLS_DC); /* a class implements this interface */ 
     220     
    210221  char *filename; 
    211222  zend_uint line_start; 
     
    401412#include <stdio.h> 
    402413static FILE *F_fp; 
     414 
     415static void binary_print(char *p, int len) { 
     416  while (len--) { 
     417    fputc(*p++, F_fp); 
     418  } 
     419  fputc('\n', F_fp); 
     420} 
     421 
     422static void log_hashkeys(char *p, HashTable *ht) 
     423{ 
     424  Bucket *b; 
     425  int i = 0; 
     426 
     427  b = ht->pListHead; 
     428 
     429  fputs(p, F_fp); 
     430  while (b) { 
     431    fprintf(F_fp, "[%d] ", i); 
     432    binary_print(b->arKey, b->nKeyLength); 
     433 
     434    b = b->pListNext; 
     435    i++; 
     436  } 
     437} 
    403438 
    404439static void pad(TSRMLS_D) { 
     
    12341269/******************************************************************************/ 
    12351270 
    1236 static inline void calc_string(char* str, int len TSRMLS_DC) { 
     1271#ifndef DEBUG 
     1272inline 
     1273#endif 
     1274static 
     1275void calc_string(char* str, int len TSRMLS_DC) { 
    12371276  if (len > MAX_DUP_STR_LEN || zend_hash_add(&MMCG(strings), str, len, &str, sizeof(char*), NULL) == SUCCESS) { 
    12381277    EACCELERATOR_ALIGN(MMCG(mem)); 
     
    13681407    for (i = 0; i < from->num_args; i++) { 
    13691408      if (from->arg_info[i].name) { 
    1370         calc_string(from->arg_info[i].name,from->arg_info[i].name_len TSRMLS_CC); 
     1409        calc_string(from->arg_info[i].name,from->arg_info[i].name_len+1 TSRMLS_CC); 
    13711410      } 
    13721411      if (from->arg_info[i].class_name) { 
    1373         calc_string(from->arg_info[i].class_name,from->arg_info[i].class_name_len TSRMLS_CC); 
     1412        calc_string(from->arg_info[i].class_name,from->arg_info[i].class_name_len+1 TSRMLS_CC); 
    13741413      } 
    13751414    } 
     
    14471486 
    14481487static void calc_class_entry(zend_class_entry* from TSRMLS_DC) { 
     1488  int i; 
     1489 
    14491490  if (from->type != ZEND_USER_CLASS) { 
    14501491    debug_printf("[%d] EACCELERATOR can't cache internal class \"%s\"\n", getpid(), from->name); 
     
    14671508    calc_string(from->parent->name, from->parent->name_length + 1  TSRMLS_CC); 
    14681509  } 
    1469  
    14701510#ifdef ZEND_ENGINE_2 
     1511#if 0 
     1512  // what's problem. why from->interfaces[i] == 0x5a5a5a5a ? 
     1513  for (i=0; i<from->num_interfaces; i++) { 
     1514    if (from->interfaces[i]) { 
     1515      calc_string(from->interfaces[i]->name, from->interfaces[i]->name_length); 
     1516    } 
     1517  } 
     1518#endif 
    14711519  if (from->filename != NULL) { 
    14721520    calc_string(from->filename, strlen(from->filename)+1 TSRMLS_CC); 
     
    17221770#ifdef DEBUG 
    17231771  pad(TSRMLS_C); 
    1724   fprintf(F_fp, "[%d] store_op_array: %s\n", getpid(), 
    1725     from->function_name ? from->function_name : "(top)"); 
     1772  fprintf(F_fp, "[%d] store_op_array: %s [scope=%s]\n", getpid(), 
     1773    from->function_name ? from->function_name : "(top)", from->scope ? from->scope->name : "NULL"); 
    17261774  fflush(F_fp); 
    17271775#endif 
     
    17421790#ifdef ZEND_ENGINE_2 
    17431791  to->num_args = from->num_args; 
     1792  to->required_num_args = from->required_num_args; 
    17441793  if (from->num_args > 0) { 
    17451794    zend_uint i; 
     
    17491798    for (i = 0; i < from->num_args; i++) { 
    17501799      if (from->arg_info[i].name) { 
    1751         to->arg_info[i].name = store_string(from->arg_info[i].name,from->arg_info[i].name_len TSRMLS_CC); 
     1800        to->arg_info[i].name = store_string(from->arg_info[i].name,from->arg_info[i].name_len+1 TSRMLS_CC); 
    17521801        to->arg_info[i].name_len = from->arg_info[i].name_len; 
    17531802      } 
    17541803      if (from->arg_info[i].class_name) { 
    1755         to->arg_info[i].class_name = store_string(from->arg_info[i].class_name,from->arg_info[i].class_name_len TSRMLS_CC); 
     1804        to->arg_info[i].class_name = store_string(from->arg_info[i].class_name,from->arg_info[i].class_name_len+1 TSRMLS_CC); 
    17561805        to->arg_info[i].class_name_len = from->arg_info[i].class_name_len; 
    17571806      } 
    17581807      to->arg_info[i].allow_null        = from->arg_info[i].allow_null; 
    17591808      to->arg_info[i].pass_by_reference = from->arg_info[i].pass_by_reference; 
     1809      to->arg_info[i].return_reference = from->arg_info[i].return_reference; 
    17601810    } 
    17611811  } 
     
    17741824         */ 
    17751825        to->function_name = store_string(from->function_name, strlen(from->function_name)+1  TSRMLS_CC); 
    1776         zend_str_tolower(to->function_name, strlen(from->function_name)); 
     1826        // XXX: revert 
     1827    // zend_str_tolower(to->function_name, strlen(from->function_name)); 
    17771828  } 
    17781829#ifdef ZEND_ENGINE_2 
     
    17901841          { 
    17911842        to->scope_name = store_string(q->arKey, q->nKeyLength TSRMLS_CC); 
    1792         to->scope_name_len = q->nKeyLength; 
     1843        to->scope_name_len = q->nKeyLength - 1; 
     1844#ifdef DEBUG 
     1845        pad(TSRMLS_C); fprintf(F_fp, "[%d]                 find scope '%s' in CG(class_table) save hashkey '%s' [%08x] as to->scope_name\n", 
     1846            getpid(), from->scope->name ? from->scope->name : "NULL", q->arKey, to->scope_name); fflush(F_fp); 
     1847#endif 
    17931848        break; 
    17941849      } 
    17951850      q = q->pListNext; 
     1851    } 
     1852    if (to->scope_name == NULL) 
     1853    { 
     1854#ifdef DEBUG 
     1855      pad(TSRMLS_C); fprintf(F_fp, "[%d]                 could not find scope '%s' in CG(class_table), saving it to NULL\n", getpid(), from->scope->name ? from->scope->name : "NULL"); fflush(F_fp); 
     1856#endif 
    17961857    } 
    17971858  } 
     
    18951956static eaccelerator_class_entry* store_class_entry(zend_class_entry* from TSRMLS_DC) { 
    18961957  eaccelerator_class_entry *to; 
     1958  int i; 
    18971959 
    18981960  EACCELERATOR_ALIGN(MMCG(mem)); 
     
    19071969  to->static_members = NULL; 
    19081970  to->num_interfaces = from->num_interfaces; 
     1971 
     1972#if 0 
     1973  // i need to check more. why this field is null. 
     1974  // 
     1975  for (i=0; i<from->num_interfaces; i++) { 
     1976    if (from->interfaces[i]) { 
     1977      to->interfaces[i] = store_string(from->interfaces[i]->name, from->interfaces[i]->name_length); 
     1978    } 
     1979  } 
     1980#endif 
     1981 
    19091982#endif 
    19101983 
    19111984#ifdef DEBUG 
    19121985  pad(TSRMLS_C); 
    1913   fprintf(F_fp, "[%d] store_class_entry: %s\n", getpid(), from->name? from->name : "(top)"); 
     1986  fprintf(F_fp, "[%d] store_class_entry: %s parent was '%s'\n", getpid(), from->name? from->name : "(top)", from->parent ? from->parent->name : "NULL"); 
    19141987  fflush(F_fp); 
    19151988  MMCG(xpad)++; 
     
    19181991  if (from->name != NULL) { 
    19191992    to->name = store_string(from->name, from->name_length+1 TSRMLS_CC); 
    1920         zend_str_tolower(to->name, from->name_length); 
     1993        //XXX: revert 
     1994    // zend_str_tolower(to->name, from->name_length); 
    19211995  } 
    19221996  if (from->parent != NULL && from->parent->name) { 
    19231997    to->parent = store_string(from->parent->name, from->parent->name_length+1 TSRMLS_CC); 
    1924     zend_str_tolower(to->parent, from->parent->name_length); 
     1998    //XXX: revert 
     1999    // zend_str_tolower(to->parent, from->parent->name_length); 
    19252000  } 
    19262001 
     
    19322007*/ 
    19332008#ifdef ZEND_ENGINE_2 
    1934   to->line_start      = from->line_start; 
    1935   to->line_end        = from->line_end; 
    1936   to->doc_comment_len = from->doc_comment_len; 
     2009  to->line_start                 = from->line_start; 
     2010  to->line_end                   = from->line_end; 
     2011  to->doc_comment_len            = from->doc_comment_len; 
     2012  to->iterator_funcs             = from->iterator_funcs; 
     2013  to->create_object              = from->create_object; 
     2014  to->get_iterator               = from->get_iterator; 
     2015  to->interface_gets_implemented = from->interface_gets_implemented; 
     2016 
    19372017  if (from->filename != NULL) { 
    19382018    to->filename = store_string(from->filename, strlen(from->filename)+1 TSRMLS_CC); 
     
    19722052  char *x; 
    19732053 
     2054#ifdef DEBUG 
     2055  pad(TSRMLS_C); fprintf(F_fp, "[%d] eaccelerator_store_int: key='%s'\n", getpid(), key); fflush(F_fp); 
     2056#endif 
     2057 
    19742058  MMCG(compress) = 1; 
    19752059  zend_hash_init(&MMCG(strings), 0, NULL, NULL, 0); 
     
    19882072  q = NULL; 
    19892073  while (c != NULL) { 
     2074#ifdef DEBUG 
     2075  pad(TSRMLS_C); fprintf(F_fp, "[%d] eaccelerator_store_int:     class hashkey=", getpid()); binary_print(c->arKey, c->nKeyLength); fflush(F_fp); 
     2076#endif 
    19902077    EACCELERATOR_ALIGN(MMCG(mem)); 
    19912078    fc = (mm_fc_entry*)MMCG(mem); 
     
    20122099  q = NULL; 
    20132100  while (f != NULL) { 
     2101#ifdef DEBUG 
     2102  pad(TSRMLS_C); fprintf(F_fp, "[%d] eaccelerator_store_int:     function hashkey='%s'\n", getpid(), f->arKey); fflush(F_fp); 
     2103#endif 
    20142104    EACCELERATOR_ALIGN(MMCG(mem)); 
    20152105    fc = (mm_fc_entry*)MMCG(mem); 
     
    22852375 
    22862376static zend_op_array* restore_op_array(zend_op_array *to, eaccelerator_op_array *from TSRMLS_DC) { 
    2287   zend_internal_function* function; 
     2377  zend_function* function; 
    22882378 
    22892379#ifdef DEBUG 
     
    23102400  to->type             = from->type; 
    23112401#ifdef ZEND_ENGINE_2 
     2402  /* this is internal function's case 
     2403   * struct zend_internal_function 
     2404        zend_uchar type; 
     2405        char *function_name;             
     2406        zend_class_entry *scope; 
     2407        zend_uint fn_flags;      
     2408        union _zend_function *prototype; 
     2409        zend_uint num_args; 
     2410        zend_uint required_num_args; 
     2411        zend_arg_info *arg_info; 
     2412        zend_bool pass_rest_by_reference; 
     2413        unsigned char return_reference; 
     2414    */ 
     2415  /* 
     2416   * typedef struct _zend_internal_function { 
     2417   * // Common elements 
     2418   *    zend_uchar type; 
     2419   *    char *function_name;             
     2420   *    zend_class_entry *scope; 
     2421   *    zend_uint fn_flags;      
     2422   *    union _zend_function *prototype; 
     2423   *    zend_uint num_args; 
     2424   *    zend_uint required_num_args; 
     2425   *    zend_arg_info *arg_info; 
     2426   *    zend_bool pass_rest_by_reference; 
     2427   *    unsigned char return_reference; 
     2428   * // END of common elements 
     2429   * 
     2430   *    void (*handler)(INTERNAL_FUNCTION_PARAMETERS); 
     2431   * } zend_internal_function; 
     2432   */ 
    23122433  to->num_args = from->num_args; 
     2434  to->required_num_args      = from->required_num_args; 
    23132435  to->arg_info = from->arg_info; 
    23142436  to->pass_rest_by_reference = from->pass_rest_by_reference; 
     
    23172439#endif 
    23182440  to->function_name    = from->function_name; 
     2441 
     2442  int    fname_len; 
     2443  char  *fname_lc; 
     2444 
     2445  if (to->function_name) 
     2446  { 
     2447    fname_len = strlen(to->function_name); 
     2448    fname_lc  = zend_str_tolower_dup(to->function_name, fname_len); 
     2449  } 
    23192450#ifdef ZEND_ENGINE_2 
    2320         to->scope            = MMCG(class_entry); 
    2321         to->fn_flags         = from->fn_flags; 
    2322         if (to->scope == NULL && from->scope_name != NULL) 
    2323         { 
    2324                 if (zend_hash_find(CG(class_table), 
    2325                         (void *)from->scope_name, from->scope_name_len, 
    2326                         (void **)&to->scope) == SUCCESS) 
    2327                 { 
    2328                         to->scope = *(zend_class_entry**)to->scope; 
    2329                 } 
    2330                 else 
    2331                 { 
    2332                         debug_printf("[%d] EACCELERATOR can't restore parent class " 
    2333                                 "\"%s\" of function \"%s\"\n", getpid(), 
    2334                                 (char*)from->scope_name, to->function_name); 
    2335                         to->scope = NULL; 
    2336                 } 
    2337         } 
     2451  to->fn_flags         = from->fn_flags; 
     2452 
     2453  /* segv74: 
     2454   * to->scope = MMCG(class_entry) 
     2455   * 
     2456   * if  from->scope_name == NULL, 
     2457   *     ; MMCG(class) == NULL  : we are in function or outside function. 
     2458   *     ; MMCG(class) != NULL  : inherited method not defined in current file, should have to find. 
     2459   *                              just LINK (zend_op_array *) to to original entry in parent, 
     2460   *                              but, with what? !!! I don't know PARENT CLASS NAME !!!! 
     2461   * 
     2462   * 
     2463   * if  from->scope_name != NULL, 
     2464   *     ; we are in class member function  
     2465   * 
     2466   *     ; we have to find appropriate (zend_class_entry*) to->scope for name from->scope_name 
     2467   *     ; if we find in CG(class_table), link to it. 
     2468   *     ; if fail, it should be MMCG(class_entry) 
     2469   *     
     2470   * am I right here ? ;-( 
     2471   */ 
     2472  if (from->scope_name != NULL) 
     2473  { 
     2474        char  *from_scope_lc = zend_str_tolower_dup(from->scope_name, from->scope_name_len); 
     2475        if (zend_hash_find(CG(class_table), (void *)from_scope_lc, from->scope_name_len+1, (void **)&to->scope) != SUCCESS) 
     2476    { 
     2477#ifdef DEBUG 
     2478      pad(TSRMLS_C); fprintf(F_fp, "[%d]                   can't find '%s' in hash. use MMCG(class_entry).\n", getpid(), from_scope_lc); fflush(F_fp); 
     2479#endif 
     2480          to->scope = MMCG(class_entry); 
     2481    } 
     2482    else 
     2483    { 
     2484#ifdef DEBUG 
     2485      pad(TSRMLS_C); fprintf(F_fp, "[%d]                   found '%s' in hash\n", getpid(), from_scope_lc); fflush(F_fp); 
     2486#endif 
     2487      to->scope = *(zend_class_entry **)(to->scope); 
     2488    } 
     2489    efree(from_scope_lc); 
     2490  } 
     2491  else 
     2492  { 
     2493#ifdef DEBUG 
     2494      pad(TSRMLS_C); fprintf(F_fp, "[%d]                   from is NULL\n", getpid()); fflush(F_fp); 
     2495#endif 
     2496    if (MMCG(class_entry)) 
     2497    { 
     2498      zend_class_entry *p; 
     2499 
     2500      for (p = MMCG(class_entry)->parent; p; p = p->parent) 
     2501      { 
     2502#ifdef DEBUG 
     2503      pad(TSRMLS_C); fprintf(F_fp, "[%d]                   checking parent '%s' have '%s'\n", getpid(), p->name, fname_lc); fflush(F_fp); 
     2504#endif 
     2505                if (zend_hash_find(&p->function_table, fname_lc, fname_len+1, (void **) &function)==SUCCESS) 
     2506        { 
     2507#ifdef DEBUG 
     2508      pad(TSRMLS_C); fprintf(F_fp, "[%d]                                   '%s' has '%s' of scope '%s'\n", getpid(), p->name, fname_lc, function->common.scope->name); fflush(F_fp); 
     2509#endif 
     2510          to->scope = function->common.scope; 
     2511          break; 
     2512        } 
     2513      } 
     2514    } 
     2515    else 
     2516      to->scope = NULL; 
     2517  } 
     2518 
     2519#ifdef DEBUG 
     2520  pad(TSRMLS_C); 
     2521  fprintf(F_fp, "[%d]                   %s's scope is '%s'\n", getpid(), 
     2522    from->function_name ? from->function_name : "(top)", to->scope ? to->scope->name : "NULL"); 
     2523  fflush(F_fp); 
     2524#endif 
     2525#if 0 
    23382526        if (to->scope != NULL) 
    23392527        { 
    23402528                unsigned int len = strlen(to->function_name); 
    23412529                char *lcname = zend_str_tolower_dup(to->function_name, len); 
     2530                char *lc_to_name = zend_str_tolower_dup(to->scope->name, to->scope->name_length); 
    23422531                /* 
    23432532                 * HOESH: this one probably the old style constructor, 
     
    23512540                 */ 
    23522541 
     2542    /* segv74: I got a question. 
     2543     * 
     2544     *         I think that, this code is reconstructing zend_class_entry thing. 
     2545     *         is it right doing this here? 
     2546     * 
     2547     *         IMHO, we can do this job in restore_class_entry(). 
     2548     *         it's not good for readablity, and dosen't have performace gain. 
     2549     */ 
     2550#ifdef DEBUG 
     2551  pad(TSRMLS_C); 
     2552  fprintf(F_fp, "        scope: %s[%d], method name: %s[%d] (%d) : to->scope->constructor=0x%08x\n", 
     2553      lcname, to->scope->name_length, lc_to_name, len, memcmp(lc_to_name, lcname, len), to->scope->constructor); 
     2554  fflush(F_fp); 
     2555#endif 
    23532556                if  ( 
    23542557                                to->scope->name_length == len && 
    2355                                 memcmp(to->scope->name, lcname, len) == 0 && 
     2558                                memcmp(lc_to_name, lcname, len) == 0 && 
    23562559                                ( 
    23572560                                        to->scope->constructor == NULL || // case 0) 
     
    23622565                        ) 
    23632566                { 
     2567#ifdef DEBUG 
     2568  pad(TSRMLS_C); 
     2569  fprintf(F_fp, "------>    matched\n"); 
     2570  fflush(F_fp); 
     2571#endif 
    23642572                        to->scope->constructor = (zend_function*)to; 
    23652573                } 
     
    23992607                } 
    24002608                efree(lcname); 
     2609        efree(lc_to_name); 
    24012610        } 
     2611#endif 
    24022612#endif 
    24032613  if (from->type == ZEND_INTERNAL_FUNCTION) 
    24042614  { 
    24052615        zend_class_entry* ce = MMCG(class_entry); 
     2616#ifdef DEBUG 
     2617    pad(TSRMLS_C); fprintf(F_fp, "[%d]                   [internal function from=%08x,to=%08x] ce='%s' [%08x]\n", getpid(), from, to, ce->name, ce); fflush(F_fp); 
     2618    if (ce) 
     2619    { 
     2620      pad(TSRMLS_C); fprintf(F_fp, "[%d]                                       ce->parent='%s' [%08x]\n", getpid(), ce->parent->name, ce->parent); fflush(F_fp); 
     2621    } 
     2622#endif 
    24062623    if (ce != NULL && 
    24072624                ce->parent != NULL && 
    24082625                zend_hash_find(&ce->parent->function_table, 
    2409                         to->function_name, strlen(to->function_name)+1, 
     2626                        fname_lc, fname_len+1, 
    24102627                        (void **) &function)==SUCCESS && 
    24112628                function->type == ZEND_INTERNAL_FUNCTION) 
    24122629        { 
    2413 #ifdef ZEND_ENGINE_2 
    2414                 efree(to); 
    2415                 to = (zend_op_array*)function; 
    2416 #else 
    2417                 ((zend_internal_function*)(to))->handler = function->handler; 
    2418 #endif 
     2630#ifdef DEBUG 
     2631      pad(TSRMLS_C); fprintf(F_fp, "[%d]                                       found in function table\n", getpid()); fflush(F_fp); 
     2632#endif 
     2633                ((zend_internal_function*)(to))->handler = ((zend_internal_function*) function)->handler; 
    24192634    } 
    24202635        else 
     
    24252640                 * damaged structure... 
    24262641                 */ 
     2642#ifdef DEBUG 
     2643      pad(TSRMLS_C); fprintf(F_fp, "[%d]                                       can't find\n", getpid()); fflush(F_fp); 
     2644#endif 
    24272645    } 
    24282646    return to; 
     
    24892707{ 
    24902708  zend_class_entry *old; 
     2709  zend_function     *f; 
     2710  int   fname_len; 
     2711  char *fname_lc; 
    24912712 
    24922713#ifdef DEBUG 
     
    25132734*/ 
    25142735  to->num_interfaces = from->num_interfaces; 
     2736  //to->num_interfaces = 0; 
    25152737  if (to->num_interfaces > 0) { 
    25162738    to->interfaces = (zend_class_entry **) emalloc(sizeof(zend_class_entry *)*to->num_interfaces); 
    2517 /* 
     2739    // XXX: 
     2740    // 
     2741    // should find out class entry. what the hell !!! 
     2742    memset(to->interfaces, 0, sizeof(zend_class_entry *)*to->num_interfaces); 
    25182743  } else { 
    25192744    to->interfaces = NULL; 
    2520 */ 
    2521   } 
     2745  } 
     2746 
     2747  to->iterator_funcs             = from->iterator_funcs; 
     2748  to->create_object              = from->create_object; 
     2749  to->get_iterator               = from->get_iterator; 
     2750  to->interface_gets_implemented = from->interface_gets_implemented; 
    25222751/* 
    25232752  to->create_object = NULL; 
     
    25332762  if (from->parent != NULL) 
    25342763  { 
    2535     int name_len = strlen(from->parent); 
    2536     if (zend_hash_find(CG(class_table), (void *)from->parent, name_len+1, (void **)&to->parent) != SUCCESS) 
     2764    int   name_len = strlen(from->parent); 
     2765    char *name_lc  = zend_str_tolower_dup(from->parent, name_len); 
     2766 
     2767    if (zend_hash_find(CG(class_table), (void *)name_lc, name_len+1, (void **)&to->parent) != SUCCESS) 
    25372768        { 
    25382769      debug_printf("[%d] EACCELERATOR can't restore parent class " 
     
    25662797#endif 
    25672798    } 
    2568   } 
     2799    efree(name_lc); 
     2800  } 
     2801  else 
     2802  { 
     2803#ifdef DEBUG 
     2804    pad(TSRMLS_C); fprintf(F_fp, "[%d] parent = NULL\n", getpid()); fflush(F_fp); 
     2805#endif 
     2806    to->parent = NULL; 
     2807  } 
     2808 
    25692809  old = MMCG(class_entry); 
    25702810  MMCG(class_entry) = to; 
     
    26222862  to->function_table.pDestructor = ZEND_FUNCTION_DTOR; 
    26232863 
     2864#ifdef ZEND_ENGINE_2 
     2865  int   cname_len = to->name_length; 
     2866  char *cname_lc  = zend_str_tolower_dup(to->name, cname_len); 
     2867 
     2868  Bucket *p = to->function_table.pListHead; 
     2869  while (p != NULL) { 
     2870    f         = p->pData; 
     2871    fname_len = strlen(f->common.function_name); 
     2872    fname_lc  = zend_str_tolower_dup(f->common.function_name, fname_len); 
     2873 
     2874    if (fname_len == cname_len && !memcmp(fname_lc, cname_lc, fname_len)) 
     2875      to->constructor = (zend_function*)f; 
     2876    else if (fname_lc[0] == '_' && fname_lc[1] == '_') 
     2877    { 
     2878      if (fname_len == sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1 && memcmp(fname_lc, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)) == 0) 
     2879        to->constructor = (zend_function*)f; 
     2880      else if (fname_len == sizeof(ZEND_DESTRUCTOR_FUNC_NAME)-1 && memcmp(fname_lc, ZEND_DESTRUCTOR_FUNC_NAME, sizeof(ZEND_DESTRUCTOR_FUNC_NAME)) == 0) 
     2881        to->destructor = (zend_function*)f; 
     2882      else if (fname_len == sizeof(ZEND_CLONE_FUNC_NAME)-1 && memcmp(fname_lc, ZEND_CLONE_FUNC_NAME, sizeof(ZEND_CLONE_FUNC_NAME)) == 0) 
     2883        to->clone = (zend_function*)f; 
     2884      else if (fname_len == sizeof(ZEND_GET_FUNC_NAME)-1 && memcmp(fname_lc, ZEND_GET_FUNC_NAME, sizeof(ZEND_GET_FUNC_NAME)) == 0) 
     2885        to->__get = (zend_function*)f; 
     2886      else if (fname_len == sizeof(ZEND_SET_FUNC_NAME)-1 && memcmp(fname_lc, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME)) == 0) 
     2887        to->__set = (zend_function*)f; 
     2888      else if (fname_len == sizeof(ZEND_CALL_FUNC_NAME)-1 && memcmp(fname_lc, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)) == 0) 
     2889        to->__call = (zend_function*)f; 
     2890    } 
     2891    efree(fname_lc); 
     2892    p = p->pListNext; 
     2893  } 
     2894  efree(cname_lc); 
     2895 
     2896#endif 
    26242897  MMCG(class_entry) = old; 
    26252898 
     
    26692942#ifdef ZEND_ENGINE_2 
    26702943  ce = restore_class_entry(NULL, (eaccelerator_class_entry *)p->fc TSRMLS_CC); 
    2671   if (ce != NULL) { 
     2944  if (ce != NULL) 
     2945#else 
     2946  if (restore_class_entry(&ce, (eaccelerator_class_entry *)p->fc TSRMLS_CC) != NULL) 
     2947#endif 
     2948  { 
     2949#ifdef ZEND_ENGINE_2 
    26722950    if (zend_hash_add(CG(class_table), p->htabkey, p->htablen, 
    2673                       &ce, sizeof(zend_class_entry*), NULL) == FAILURE) { 
    2674 #else 
    2675   if (restore_class_entry(&ce, (eaccelerator_class_entry *)p->fc TSRMLS_CC) != NULL) { 
     2951                      &ce, sizeof(zend_class_entry*), NULL) == FAILURE) 
     2952#else 
    26762953    if (zend_hash_add(CG(class_table), p->htabkey, p->htablen, 
    2677                       &ce, sizeof(zend_class_entry), NULL) == FAILURE) { 
    2678 #endif 
     2954                      &ce, sizeof(zend_class_entry), NULL) == FAILURE) 
     2955#endif 
     2956    { 
    26792957      CG(in_compilation) = 1; 
    26802958      CG(compiled_filename) = MMCG(mem); 
     
    26872965    } 
    26882966  } 
     2967 
    26892968} 
    26902969 
     
    30513330  t = eaccelerator_restore(realname, &buf, &nreloads, compile_time TSRMLS_CC); 
    30523331 
     3332// segv74: really cheap work around to auto_global problem. 
     3333//         it makes just in time to every time. 
     3334#ifdef ZEND_ENGINE_2 
     3335  zend_is_auto_global("_GET", sizeof("_SERVER")-1 TSRMLS_CC); 
     3336  zend_is_auto_global("_POST", sizeof("_SERVER")-1 TSRMLS_CC); 
     3337  zend_is_auto_global("_COOKIE", sizeof("_SERVER")-1 TSRMLS_CC); 
     3338  zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC); 
     3339  zend_is_auto_global("_ENV", sizeof("_ENV")-1 TSRMLS_CC); 
     3340  zend_is_auto_global("_REQUEST", sizeof("_REQUEST")-1 TSRMLS_CC); 
     3341  zend_is_auto_global("_FILES", sizeof("_SERVER")-1 TSRMLS_CC); 
     3342#endif 
    30533343  if (t != NULL) { 
    30543344    if (eaccelerator_debug > 0) { 
     
    30823372#if defined(DEBUG) 
    30833373    fprintf(F_fp, "[%d] Leave COMPILE\n",getpid()); fflush(F_fp); 
     3374    //dprint_compiler_retval(t, 1); 
    30843375#endif 
    30853376    return t; 
     
    30903381    HashTable* orig_function_table; 
    30913382    HashTable* orig_class_table; 
     3383    HashTable* orig_eg_class_table; 
    30923384    HashTable tmp_function_table; 
    30933385    HashTable tmp_class_table; 
     
    30983390#if defined(DEBUG) || defined(TEST_PERFORMANCE) 
    30993391    fprintf(F_fp, "\t[%d] compile_file: marking\n",getpid()); fflush(F_fp); 
     3392    if (CG(class_table) != EG(class_table)) 
     3393    { 
     3394      fprintf(F_fp, "\t[%d] oops, CG(class_table)[%08x] != EG(class_table)[%08x]\n", getpid(), CG(class_table), EG(class_table)); 
     3395      //log_hashkeys("CG(class_table)\n", CG(class_table)); 
     3396      //log_hashkeys("EG(class_table)\n", EG(class_table)); 
     3397    } 
     3398    else 
     3399      fprintf(F_fp, "\t[%d] OKAY. That what I thought, CG(class_table)[%08x] == EG(class_table)[%08x]\n", getpid(), CG(class_table), EG(class_table)); 
     3400      //log_hashkeys("CG(class_table)\n", CG(class_table)); 
    31003401#endif 
    31013402 
     
    31073408    zend_hash_init_ex(&tmp_class_table, 10, NULL, ZEND_CLASS_DTOR, 1, 0); 
    31083409    zend_hash_copy(&tmp_class_table, &eaccelerator_global_class_table, NULL, &tmp_class, sizeof(zend_class_entry)); 
     3410 
    31093411    orig_class_table = CG(class_table);; 
    31103412    CG(class_table) = &tmp_class_table; 
     3413#ifdef ZEND_ENGINE_2 
     3414    orig_eg_class_table = EG(class_table);; 
     3415    EG(class_table) = &tmp_class_table; 
     3416#endif 
    31113417 
    31123418    /* Storing global pre-compiled functions and classes */ 
     
    31183424    fprintf(F_fp, "\t[%d] compile_file: compiling (%ld)\n",getpid(),elapsed_time(&tv_start)); fflush(F_fp); 
    31193425#else 
    3120     fprintf(F_fp, "\t[%d] compile_file: compiling\n",getpid()); fflush(F_fp); 
     3426    fprintf(F_fp, "\t[%d] compile_file: compiling tmp_class_table=%d class_table=%d\n", getpid(), tmp_class_table.nNumOfElements, orig_class_table->nNumOfElements); fflush(F_fp); 
    31213427#endif 
    31223428#endif 
     
    31313437      CG(function_table) = orig_function_table; 
    31323438      CG(class_table) = orig_class_table; 
     3439#ifdef ZEND_ENGINE_2 
     3440      EG(class_table) = orig_eg_class_table; 
     3441#endif 
    31333442      bailout = 1; 
    31343443    } zend_end_try(); 
     
    31363445      zend_bailout(); 
    31373446    } 
     3447#if defined(DEBUG) 
     3448    //log_hashkeys("class_table\n", CG(class_table)); 
     3449#endif 
    31383450 
    31393451/*??? 
     
    32173529    CG(function_table) = orig_function_table; 
    32183530    CG(class_table) = orig_class_table; 
     3531#ifdef ZEND_ENGINE_2 
     3532    EG(class_table) = orig_eg_class_table; 
     3533#ifdef DEBUG 
     3534    fprintf(F_fp, "\t[%d] restoring CG(class_table)[%08x] != EG(class_table)[%08x]\n", getpid(), CG(class_table), EG(class_table)); 
     3535#endif 
     3536#endif 
    32193537    while (function_table_tail != NULL) { 
    32203538      zend_op_array *op_array = (zend_op_array*)function_table_tail->pData; 
     
    32883606#if defined(DEBUG) 
    32893607  fprintf(F_fp, "[%d] Leave COMPILE\n",getpid()); fflush(F_fp); 
     3608  //dprint_compiler_retval(t, 0); 
    32903609#endif 
    32913610  return t; 
     
    52885607  EACCELERATOR_EXTENSION_NAME, 
    52895608  EACCELERATOR_VERSION, 
    5290   "eAccelerator Team", 
     5609  "eAccelerator", 
    52915610  "http://eaccelerator.sourceforge.net", 
    5292   "Copyright (c) 2004-2005 eAccelerator Team", 
     5611  "Copyright (c) 2004-2005 eAccelerator", 
    52935612  eaccelerator_zend_startup, 
    52945613  NULL, 
     
    53175636  EACCELERATOR_EXTENSION_NAME, 
    53185637  EACCELERATOR_VERSION, 
    5319   "eAccelerator Team", 
     5638  "eAccelerator", 
    53205639  "http://eaccelerator.sourceforge.net", 
    5321   "Copyright (c) 2004-2005 eAccelerator Team", 
     5640  "Copyright (c) 2004-2004 eAccelerator", 
    53225641  eaccelerator_zend_startup, 
    53235642  NULL, 
     
    58266145      if (x->type == ZEND_USER_CLASS) { 
    58276146#ifdef ZEND_ENGINE_2 
    5828         zend_printf("<tr><td><a href=\"?file=%s&class=%s\">%s</a> [\n", 
     6147        zend_printf("<tr><td><a href=\"?file=%s&class=%s\"&Horde=22c8f7474b79194f32569fc1af447f5b>%s</a> [\n", 
    58296148        p->realfilename, class, class); 
    58306149        if (x->ce_flags & ZEND_ACC_FINAL_CLASS) { 
     
    58446163        ZEND_PUTS("]</td></tr>"); 
    58456164#else 
    5846         zend_printf("<tr><td><a href=\"?file=%s&class=%s\">%s</a></td></tr>\n", 
     6165        zend_printf("<tr><td><a href=\"?file=%s&class=%s\"&Horde=22c8f7474b79194f32569fc1af447f5b>%s</a></td></tr>\n", 
    58476166          p->realfilename, class, class); 
    58486167#endif 
     
    58656184      if (func[0] == '\000' && fc->htablen > 0) func[0] = '-'; 
    58666185      if (((zend_function*)(fc->fc))->type == ZEND_USER_FUNCTION) { 
    5867         zend_printf("<tr><td><a href=\"?file=%s&func=%s\">%s</a></td></tr>\n", 
     6186        zend_printf("<tr><td><a href=\"?file=%s&func=%s\"&Horde=22c8f7474b79194f32569fc1af447f5b>%s</a></td></tr>\n", 
    58686187          p->realfilename, func, func); 
    58696188      } else { 
     
    59846303      if (x->type == ZEND_USER_FUNCTION) { 
    59856304#ifdef ZEND_ENGINE_2 
    5986         zend_printf("<tr><td><a href=\"?file=%s&class=%s&func=%s\">%s</a> [", p->realfilename, class, q->arKey, q->arKey); 
     6305        zend_printf("<tr><td><a href=\"?file=%s&class=%s&func=%s\"&Horde=22c8f7474b79194f32569fc1af447f5b>%s</a> [", p->realfilename, class, q->arKey, q->arKey); 
    59876306        if (x->fn_flags & ZEND_ACC_STATIC) { 
    59886307          ZEND_PUTS("static "); 
     
    60036322        ZEND_PUTS("]</td></tr>"); 
    60046323#else 
    6005         zend_printf("<tr><td><a href=\"?file=%s&class=%s&func=%s\">%s</a></td></tr>\n", p->realfilename, class, q->arKey, q->arKey); 
     6324        zend_printf("<tr><td><a href=\"?file=%s&class=%s&func=%s\"&Horde=22c8f7474b79194f32569fc1af447f5b>%s</a></td></tr>\n", p->realfilename, class, q->arKey, q->arKey); 
    60066325#endif 
    60076326      } else { 
     
    65696888  EACCELERATOR_LOCK_RD(); 
    65706889  EACCELERATOR_PROTECT(); 
    6571   ZEND_PUTS("<form method=\"POST\"><center>\n"); 
     6890  ZEND_PUTS("<form method=\"POST\"><input type=\"hidden\" name=\"Horde\" value=\"22c8f7474b79194f32569fc1af447f5b\" /><center>\n"); 
    65726891  if (MMCG(enabled) && eaccelerator_mm_instance->enabled) { 
    65736892    ZEND_PUTS("<input type=\"submit\" name=\"disable\" value=\"Disable\" title=\"Disable caching of PHP scripts\" style=\"width:100px\">\n"); 
     
    66226941    format_size(s, p->size, 0); 
    66236942#ifdef WITH_EACCELERATOR_DISASSEMBLER 
    6624     zend_printf("<tr valign=\"bottom\" bgcolor=\"#cccccc\"><td bgcolor=\"#ccccff\"><b><a href=\"%s?file=%s\">", 
     6943    zend_printf("<tr valign=\"bottom\" bgcolor=\"#cccccc\"><td bgcolor=\"#ccccff\"><b><a href=\"%s?file=%s\"&Horde=22c8f7474b79194f32569fc1af447f5b>", 
    66256944      php_self?(*php_self)->value.str.val:"", 
    66266945      p->realfilename); 
  • eaccelerator/trunk/eaccelerator_version.h

    r4 r17  
    11#ifndef EACCELERATOR_VERSION 
    2 #define EACCELERATOR_VERSION "0.9.0
     2#define EACCELERATOR_VERSION "0.9.1
    33#endif 
  • eaccelerator/trunk/optimize.c

    r12 r17  
    261261             case ZEND_FE_FETCH: 
    262262#ifdef ZEND_ENGINE_2 
     263             case ZEND_ASSIGN_DIM: 
    263264             case ZEND_DECLARE_CLASS: 
    264265             case ZEND_DECLARE_INHERITED_CLASS: