Changeset 294

Show
Ignore:
Timestamp:
02/13/07 18:39:01 (1 year ago)
Author:
bart
Message:

Revert some changes form changeset @256 to fix bug #199

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • eaccelerator/trunk/ChangeLog

    r292 r294  
    88            reordered some conditional includes to reduce ifdef statements 
    99        * Check if those array indices are set before testing them in control.php 
     10        * Revert some changes form changeset @256 to fix bug #199 
    1011 
    11122007-01-29  Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 
  • eaccelerator/trunk/eaccelerator.c

    r291 r294  
    9292static int eaccelerator_is_extension      = 0; 
    9393zend_extension* ZendOptimizer = NULL; 
     94 
     95static HashTable eaccelerator_global_function_table; 
     96static HashTable eaccelerator_global_class_table; 
    9497 
    9598int binary_eaccelerator_version[2]; 
     
    12531256    return t; 
    12541257  } else { // not in cache or must be recompiled 
    1255     Bucket *function_table_tail; 
    1256     Bucket *class_table_tail; 
    1257     int ea_bailout; 
     1258                Bucket *function_table_tail; 
     1259                Bucket *class_table_tail; 
     1260                HashTable* orig_function_table; 
     1261                HashTable* orig_class_table; 
     1262                HashTable* orig_eg_class_table = NULL; 
     1263                HashTable tmp_function_table; 
     1264                HashTable tmp_class_table; 
     1265                zend_function tmp_func; 
     1266                zend_class_entry tmp_class; 
     1267                int ea_bailout; 
    12581268 
    12591269#ifdef DEBUG 
     
    12691279#endif 
    12701280 
     1281 
     1282    zend_hash_init_ex(&tmp_function_table, 100, NULL, ZEND_FUNCTION_DTOR, 1, 0); 
     1283    zend_hash_copy(&tmp_function_table, &eaccelerator_global_function_table, NULL, &tmp_func, sizeof(zend_function)); 
     1284    orig_function_table = CG(function_table); 
     1285    CG(function_table) = &tmp_function_table; 
     1286 
     1287    zend_hash_init_ex(&tmp_class_table, 10, NULL, ZEND_CLASS_DTOR, 1, 0); 
     1288    zend_hash_copy(&tmp_class_table, &eaccelerator_global_class_table, NULL, &tmp_class, sizeof(zend_class_entry)); 
     1289 
     1290    orig_class_table = CG(class_table);; 
     1291    CG(class_table) = &tmp_class_table; 
     1292#ifdef ZEND_ENGINE_2 
     1293    orig_eg_class_table = EG(class_table);; 
     1294    EG(class_table) = &tmp_class_table; 
     1295#endif 
     1296 
    12711297    /* Storing global pre-compiled functions and classes */ 
    12721298    function_table_tail = CG(function_table)->pListTail; 
     
    12841310      t = mm_saved_zend_compile_file(file_handle, type TSRMLS_CC); 
    12851311    } zend_catch { 
     1312      CG(function_table) = orig_function_table; 
     1313      CG(class_table) = orig_class_table; 
     1314#ifdef ZEND_ENGINE_2 
     1315      EG(class_table) = orig_eg_class_table; 
     1316#endif 
    12861317      ea_bailout = 1; 
    12871318    } zend_end_try(); 
     
    13151346      class_table_tail = class_table_tail ? class_table_tail->pListNext : CG(class_table)->pListHead; 
    13161347    } 
     1348    CG(function_table) = orig_function_table; 
     1349    CG(class_table) = orig_class_table; 
     1350#ifdef ZEND_ENGINE_2 
     1351    EG(class_table) = orig_eg_class_table; 
     1352    DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] restoring CG(class_table)[%08x] != EG(class_table)[%08x]\n",  
     1353                getpid(), CG(class_table), EG(class_table))); 
     1354#endif 
     1355    while (function_table_tail != NULL) { 
     1356      zend_op_array *op_array = (zend_op_array*)function_table_tail->pData; 
     1357      if (op_array->type == ZEND_USER_FUNCTION) { 
     1358        if (zend_hash_add(CG(function_table), function_table_tail->arKey, function_table_tail->nKeyLength, op_array,  
     1359                    sizeof(zend_op_array), NULL) == FAILURE && function_table_tail->arKey[0] != '\000') { 
     1360          CG(in_compilation) = 1; 
     1361          CG(compiled_filename) = file_handle->opened_path; 
     1362#ifdef ZEND_ENGINE_2 
     1363          CG(zend_lineno) = op_array->line_start; 
     1364#else 
     1365          CG(zend_lineno) = op_array->opcodes[0].lineno; 
     1366#endif 
     1367          zend_error(E_ERROR, "Cannot redeclare %s()", function_table_tail->arKey); 
     1368        } 
     1369      } 
     1370      function_table_tail = function_table_tail->pListNext; 
     1371    } 
     1372    while (class_table_tail != NULL) { 
     1373#ifdef ZEND_ENGINE_2 
     1374      zend_class_entry **ce = (zend_class_entry**)class_table_tail->pData; 
     1375      if ((*ce)->type == ZEND_USER_CLASS) { 
     1376        if (zend_hash_add(CG(class_table), class_table_tail->arKey, class_table_tail->nKeyLength,  
     1377                    ce, sizeof(zend_class_entry*), NULL) == FAILURE && class_table_tail->arKey[0] != '\000') { 
     1378          CG(in_compilation) = 1; 
     1379          CG(compiled_filename) = file_handle->opened_path; 
     1380          CG(zend_lineno) = (*ce)->line_start; 
     1381#else 
     1382      zend_class_entry *ce = (zend_class_entry*)class_table_tail->pData; 
     1383      if (ce->type == ZEND_USER_CLASS) { 
     1384        if (ce->parent != NULL) { 
     1385          if (zend_hash_find(CG(class_table), (void*)ce->parent->name, ce->parent->name_length+1, (void **)&ce->parent) != SUCCESS) { 
     1386            ce->parent = NULL; 
     1387          } 
     1388        } 
     1389        if (zend_hash_add(CG(class_table), class_table_tail->arKey, class_table_tail->nKeyLength, ce,  
     1390                    sizeof(zend_class_entry), NULL) == FAILURE && class_table_tail->arKey[0] != '\000') { 
     1391          CG(in_compilation) = 1; 
     1392          CG(compiled_filename) = file_handle->opened_path; 
     1393          CG(zend_lineno) = 0; 
     1394#endif 
     1395          zend_error(E_ERROR, "Cannot redeclare class %s", class_table_tail->arKey); 
     1396        } 
     1397      } 
     1398      class_table_tail = class_table_tail->pListNext; 
     1399    } 
     1400    tmp_function_table.pDestructor = NULL; 
     1401    tmp_class_table.pDestructor = NULL; 
     1402    zend_hash_destroy(&tmp_function_table); 
     1403    zend_hash_destroy(&tmp_class_table); 
    13171404  } 
    13181405  DBG(ea_debug_printf, (EA_TEST_PERFORMANCE, "\t[%d] compile_file: end (%ld)\n", getpid(), ea_debug_elapsed_time(&tv_start)));