Changeset 378


Ignore:
Timestamp:
2007-05-07T19:21:35+02:00 (8 years ago)
Author:
moo
Message:

merged[344] [345] [346] from trunk->1.2: fixed #59: pass by reference for internal function was broken

Location:
branches/1.2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/1.2

  • branches/1.2/NEWS

    r377 r378  
    88 * #86: remove/edit variable in admin page 
    99 * fixed #77: hits/misses was not updated 
     10 * fixed #59: pass by reference for internal function was broken 
    1011 * fixed #56: xcache_set segfaults when xcache.var_size=0 
    1112  
  • branches/1.2/utils.c

    r295 r378  
    11 
    22#include "xcache.h" 
     3#include "stack.h" 
     4#include "xcache_globals.h" 
    35#include "utils.h" 
    46#ifdef ZEND_ENGINE_2_1 
     
    534536/* }}} */ 
    535537#endif 
     538 
     539void xc_zend_class_add_ref(zend_class_entry ZESW(*ce, **ce)) 
     540{ 
     541#ifdef ZEND_ENGINE_2 
     542    (*ce)->refcount++; 
     543#else 
     544    (*ce->refcount)++; 
     545#endif 
     546} 
     547 
    536548xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /* {{{ */ 
    537549{ 
    538550    HashTable *h; 
     551 
    539552    if (sandbox) { 
    540553        memset(sandbox, 0, sizeof(sandbox[0])); 
     
    573586    h = OG(function_table); 
    574587    zend_hash_init_ex(&TG(function_table), 128, NULL, h->pDestructor, h->persistent, h->bApplyProtection); 
     588    { 
     589        zend_function tmp_func; 
     590        zend_hash_copy(&TG(function_table), &XG(internal_function_table), (copy_ctor_func_t) function_add_ref, (void *) &tmp_func, sizeof(tmp_func)); 
     591    } 
     592    TG(internal_class_tail) = TG(function_table).pListTail; 
     593 
    575594    h = OG(class_table); 
    576595    zend_hash_init_ex(&TG(class_table),     16, NULL, h->pDestructor, h->persistent, h->bApplyProtection); 
     596#if 0 && TODO 
     597    { 
     598        xc_cest_t tmp_cest; 
     599        zend_hash_copy(&TG(class_table), &XG(internal_class_table), (copy_ctor_func_t) xc_zend_class_add_ref, (void *) &tmp_cest, sizeof(tmp_cest)); 
     600    } 
     601#endif 
     602    TG(internal_class_tail) = TG(class_table).pListTail; 
     603 
    577604#ifdef ZEND_ENGINE_2_1 
    578605    /* shallow copy, don't destruct */ 
     
    619646#endif 
    620647 
    621     b = TG(function_table).pListHead; 
     648    b = TG(internal_function_tail) ? TG(internal_function_tail)->pListNext : TG(function_table).pListHead; 
    622649    /* install function */ 
    623650    while (b != NULL) { 
     
    628655    } 
    629656 
    630     b = TG(class_table).pListHead; 
     657    b = TG(internal_class_tail) ? TG(internal_class_tail)->pListNext : TG(class_table).pListHead; 
    631658    /* install class */ 
    632659    while (b != NULL) { 
  • branches/1.2/utils.h

    r268 r378  
    5353    HashTable tmp_class_table; 
    5454    HashTable tmp_auto_globals; 
     55    Bucket    *tmp_internal_function_tail; 
     56    Bucket    *tmp_internal_class_tail; 
    5557} xc_sandbox_t; 
    5658 
     59void xc_zend_class_add_ref(zend_class_entry ZESW(*ce, **ce)); 
    5760xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC); 
    5861void xc_sandbox_free(xc_sandbox_t *sandbox, int install TSRMLS_DC); 
  • branches/1.2/xcache.c

    r377 r378  
    10231023        Bucket *b; 
    10241024        unsigned int i; 
     1025        unsigned int j; 
    10251026 
    10261027#define COPY_H(vartype, var, cnt, name, datatype) do {        \ 
    1027     for (i = 0; b; i ++, b = b->pListNext) {                  \ 
    1028         vartype *data = &php.var[i];                          \ 
     1028    for (i = 0, j = 0; b; i ++, b = b->pListNext) {           \ 
     1029        vartype *data = &php->var[j];                         \ 
    10291030                                                              \ 
    10301031        if (i < old_##cnt) {                                  \ 
    10311032            continue;                                         \ 
    10321033        }                                                     \ 
     1034        j ++;                                                 \ 
    10331035                                                              \ 
    10341036        assert(i < old_##cnt + php.cnt);                      \ 
     
    14431445    int i; 
    14441446 
     1447    if (XG(internal_function_table).nTableSize == 0) { 
     1448        zend_function tmp_func; 
     1449        xc_cest_t tmp_cest; 
     1450 
     1451        zend_hash_init_ex(&XG(internal_function_table), 100, NULL, NULL, 1, 0); 
     1452        zend_hash_copy(&XG(internal_function_table), CG(function_table), (copy_ctor_func_t) function_add_ref, &tmp_func, sizeof(tmp_func)); 
     1453 
     1454        zend_hash_init_ex(&XG(internal_class_table), 10, NULL, NULL, 1, 0); 
     1455        zend_hash_copy(&XG(internal_class_table), CG(class_table), (copy_ctor_func_t) xc_zend_class_add_ref, &tmp_cest, sizeof(tmp_cest)); 
     1456    } 
    14451457    if (xc_php_hcache.size && !XG(php_holds)) { 
    14461458        XG(php_holds) = calloc(xc_php_hcache.size, sizeof(xc_stack_t)); 
     
    15161528        xcache_globals->var_holds = NULL; 
    15171529    } 
     1530 
     1531    zend_hash_destroy(&xcache_globals->internal_function_table); 
     1532    zend_hash_destroy(&xcache_globals->internal_class_table); 
    15181533} 
    15191534/* }}} */ 
  • branches/1.2/xcache_globals.h

    r367 r378  
    1616    long   var_ttl; 
    1717    zend_bool auth_enabled; 
     18 
     19    HashTable internal_function_table; 
     20    HashTable internal_class_table; 
    1821ZEND_END_MODULE_GLOBALS(xcache) 
    1922 
Note: See TracChangeset for help on using the changeset viewer.