Changeset 209

Show
Ignore:
Timestamp:
05/08/06 15:17:02 (2 years ago)
Author:
bart
Message:

Changed the filter logic a bit, this fixes bug #72

Files:

Legend:

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

    r208 r209  
    33        * Make the disassembler do openbasedir checks before showing a file,  
    44          this fixes bug #59 
     5        * Changed the filter logic a bit, this fixes bug #72 
    56 
    672006-05-07  Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 
  • eaccelerator/trunk/eaccelerator.c

    r207 r209  
    960960  char p,k; 
    961961  int ok, neg; 
    962  
     962   
    963963  while (1) { 
    964964    p = *pat++; 
     
    10291029  mm_cond_entry *p; 
    10301030  int ok; 
    1031  
     1031fprintf(stderr, "Going to inspect %s\n", realname);fflush(stderr); 
    10321032  if (EAG(cond_list) == NULL) { 
    10331033    return 1; 
     
    12521252  struct timeval tv_start; 
    12531253#endif 
     1254  int ok_to_cache = 0; 
    12541255 
    12551256#ifdef EACCELERATOR_USE_INODE 
     
    12691270        ea_debug_log("EACCELERATOR: Warning: \"%s\" is cached but it's mtime is in the future.\n", file_handle->filename); 
    12701271  } 
    1271    
    1272   if (!EAG(enabled) || (eaccelerator_mm_instance == NULL) || 
     1272 
     1273  ok_to_cache = eaccelerator_ok_to_cache(file_handle->filename TSRMLS_CC); 
     1274  
     1275  // eAccelerator isn't working, so just compile the file 
     1276  if (!EAG(enabled) || (eaccelerator_mm_instance == NULL) ||  
    12731277      !eaccelerator_mm_instance->enabled || file_handle == NULL || 
    1274       file_handle->filename == NULL || stat_result != 0 || 
    1275 #ifdef EACCELERATOR_USE_INODE 
    1276       0) { 
    1277 #else 
    1278       !eaccelerator_ok_to_cache(realname TSRMLS_CC)) { 
    1279 #endif 
     1278      file_handle->filename == NULL || stat_result != 0 || !ok_to_cache) { 
    12801279    DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] compile_file: compiling\n", getpid())); 
    12811280    t = mm_saved_zend_compile_file(file_handle, type TSRMLS_CC); 
     
    13071306  zend_is_auto_global("_FILES", sizeof("_FILES")-1 TSRMLS_CC); 
    13081307#endif 
    1309   if (t != NULL) { 
     1308 
     1309  if (t != NULL) { // restore from cache 
    13101310#ifdef DEBUG 
    13111311    ea_debug_log("[%d] EACCELERATOR hit: \"%s\"\n", getpid(), t->filename); 
     
    13131313    ea_debug_log("EACCELERATOR hit: \"%s\"\n", t->filename); 
    13141314#endif 
    1315     /* restored from cache */ 
    13161315 
    13171316    zend_llist_add_element(&CG(open_files), file_handle); 
     
    13381337    DBG(ea_debug_printf, (EA_DEBUG, "[%d] Leave COMPILE\n", getpid())); 
    13391338    return t; 
    1340   } else { 
    1341     /* not in cache or must be recompiled */ 
     1339  } else { // not in cache or must be recompiled 
    13421340    Bucket *function_table_tail; 
    13431341    Bucket *class_table_tail; 
     
    13521350 
    13531351    DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] compile_file: marking\n", getpid())); 
    1354     if (CG(class_table) != EG(class_table)) 
    1355     { 
    1356       DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] oops, CG(class_table)[%08x] != EG(class_table)[%08x]\n", getpid(), CG(class_table), EG(class_table))); 
     1352    if (CG(class_table) != EG(class_table)) { 
     1353      DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] oops, CG(class_table)[%08x] != EG(class_table)[%08x]\n",  
     1354                                               getpid(), CG(class_table), EG(class_table))); 
    13571355      DBG(ea_debug_log_hashkeys, ("CG(class_table)\n", CG(class_table))); 
    13581356      DBG(ea_debug_log_hashkeys, ("EG(class_table)\n", EG(class_table))); 
    1359     } 
    1360     else { 
    1361       DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] OKAY. That what I thought, CG(class_table)[%08x] == EG(class_table)[%08x]\n", getpid(), CG(class_table), EG(class_table))); 
     1357    } else { 
     1358      DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] OKAY. That what I thought, CG(class_table)[%08x] == EG(class_table)[%08x]\n",  
     1359                                               getpid(), CG(class_table), EG(class_table))); 
    13621360      DBG(ea_debug_log_hashkeys, ("CG(class_table)\n", CG(class_table))); 
    13631361    } 
     
    13841382    DBG(ea_debug_printf, (EA_TEST_PERFORMANCE, "\t[%d] compile_file: compiling (%ld)\n",getpid(),ea_debug_elapsed_time(&tv_start))); 
    13851383    DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] compile_file: compiling tmp_class_table=%d class_table=%d\n",  
    1386         getpid(), tmp_class_table.nNumOfElements, orig_class_table->nNumOfElements)); 
     1384          getpid(), tmp_class_table.nNumOfElements, orig_class_table->nNumOfElements)); 
    13871385    if (EAG(optimizer_enabled) && eaccelerator_mm_instance->optimizer_enabled) { 
    13881386      EAG(compiler) = 1; 
     
    14111409*/ 
    14121410    EAG(compiler) = 0; 
    1413     if (t != NULL && file_handle->opened_path != NULL && 
    1414 #ifdef EACCELERATOR_USE_INODE 
    1415         eaccelerator_ok_to_cache(file_handle->opened_path TSRMLS_CC)) { 
    1416 #else 
    1417         (eaccelerator_check_mtime || 
     1411    if (t != NULL && file_handle->opened_path != NULL && (eaccelerator_check_mtime || 
    14181412         ((stat(file_handle->opened_path, &buf) == 0) && S_ISREG(buf.st_mode)))) { 
    1419 #endif 
    14201413      DBG(ea_debug_printf, (EA_TEST_PERFORMANCE, "\t[%d] compile_file: storing in cache (%ld)\n", getpid(), ea_debug_elapsed_time(&tv_start))); 
    14211414      DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] compile_file: storing in cache\n", getpid())); 
     
    14661459      } 
    14671460#endif 
    1468       function_table_tail = function_table_tail?function_table_tail->pListNext: 
    1469                                                 CG(function_table)->pListHead; 
    1470       class_table_tail = class_table_tail?class_table_tail->pListNext: 
    1471                                           CG(class_table)->pListHead; 
    1472       if (eaccelerator_store(file_handle->opened_path, &buf, nreloads, t, 
    1473                         function_table_tail, class_table_tail TSRMLS_CC)) { 
     1461      function_table_tail = function_table_tail?function_table_tail->pListNext:CG(function_table)->pListHead; 
     1462      class_table_tail = class_table_tail?class_table_tail->pListNext:CG(class_table)->pListHead; 
     1463      if (eaccelerator_store(file_handle->opened_path, &buf, nreloads, t, function_table_tail, class_table_tail TSRMLS_CC)) { 
    14741464#ifdef DEBUG 
    1475         ea_debug_log("[%d] EACCELERATOR %s: \"%s\"\n", getpid(), 
    1476               (nreloads == 1) ? "cached" : "re-cached", file_handle->opened_path); 
    1477 #else 
    1478         ea_debug_log("EACCELERATOR %s: \"%s\"\n", 
    1479           (nreloads == 1) ? "cached" : "re-cached", file_handle->opened_path); 
     1465        ea_debug_log("[%d] EACCELERATOR %s: \"%s\"\n", getpid(), (nreloads == 1) ? "cached" : "re-cached", file_handle->opened_path); 
     1466#else 
     1467        ea_debug_log("EACCELERATOR %s: \"%s\"\n", (nreloads == 1) ? "cached" : "re-cached", file_handle->opened_path); 
    14801468#endif 
    14811469      } else { 
     
    14871475      } 
    14881476    } else { 
    1489       function_table_tail = function_table_tail?function_table_tail->pListNext: 
    1490                                                 CG(function_table)->pListHead; 
    1491       class_table_tail = class_table_tail?class_table_tail->pListNext: 
    1492                                           CG(class_table)->pListHead; 
     1477      function_table_tail = function_table_tail?function_table_tail->pListNext:CG(function_table)->pListHead; 
     1478      class_table_tail = class_table_tail?class_table_tail->pListNext:CG(class_table)->pListHead; 
    14931479    } 
    14941480    CG(function_table) = orig_function_table; 
     
    14961482#ifdef ZEND_ENGINE_2 
    14971483    EG(class_table) = orig_eg_class_table; 
    1498     DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] restoring CG(class_table)[%08x] != EG(class_table)[%08x]\n", getpid(), CG(class_table), EG(class_table))); 
     1484    DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] restoring CG(class_table)[%08x] != EG(class_table)[%08x]\n",  
     1485                getpid(), CG(class_table), EG(class_table))); 
    14991486#endif 
    15001487    while (function_table_tail != NULL) { 
    15011488      zend_op_array *op_array = (zend_op_array*)function_table_tail->pData; 
    15021489      if (op_array->type == ZEND_USER_FUNCTION) { 
    1503         if (zend_hash_add(CG(function_table), 
    1504                           function_table_tail->arKey, 
    1505                           function_table_tail->nKeyLength, 
    1506                           op_array, sizeof(zend_op_array), NULL) == FAILURE && 
    1507             function_table_tail->arKey[0] != '\000') { 
     1490        if (zend_hash_add(CG(function_table), function_table_tail->arKey, function_table_tail->nKeyLength, op_array,  
     1491                    sizeof(zend_op_array), NULL) == FAILURE && function_table_tail->arKey[0] != '\000') { 
    15081492          CG(in_compilation) = 1; 
    15091493          CG(compiled_filename) = file_handle->opened_path; 
     
    15221506      zend_class_entry **ce = (zend_class_entry**)class_table_tail->pData; 
    15231507      if ((*ce)->type == ZEND_USER_CLASS) { 
    1524         if (zend_hash_add(CG(class_table), 
    1525                           class_table_tail->arKey, 
    1526                           class_table_tail->nKeyLength, 
    1527                           ce, sizeof(zend_class_entry*), NULL) == FAILURE && 
    1528             class_table_tail->arKey[0] != '\000') { 
     1508        if (zend_hash_add(CG(class_table), class_table_tail->arKey, class_table_tail->nKeyLength,  
     1509                    ce, sizeof(zend_class_entry*), NULL) == FAILURE && class_table_tail->arKey[0] != '\000') { 
    15291510          CG(in_compilation) = 1; 
    15301511          CG(compiled_filename) = file_handle->opened_path; 
     
    15341515      if (ce->type == ZEND_USER_CLASS) { 
    15351516        if (ce->parent != NULL) { 
    1536           if (zend_hash_find(CG(class_table), (void*)ce->parent->name, ce->parent->name_length+1, (void **)&ce->parent) != SUCCESS) 
    1537                   { 
     1517          if (zend_hash_find(CG(class_table), (void*)ce->parent->name, ce->parent->name_length+1, (void **)&ce->parent) != SUCCESS) { 
    15381518            ce->parent = NULL; 
    15391519          } 
    15401520        } 
    1541         if (zend_hash_add(CG(class_table), 
    1542                           class_table_tail->arKey, 
    1543                           class_table_tail->nKeyLength, 
    1544                           ce, sizeof(zend_class_entry), NULL) == FAILURE && 
    1545             class_table_tail->arKey[0] != '\000') { 
     1521        if (zend_hash_add(CG(class_table), class_table_tail->arKey, class_table_tail->nKeyLength, ce,  
     1522                    sizeof(zend_class_entry), NULL) == FAILURE && class_table_tail->arKey[0] != '\000') { 
    15461523          CG(in_compilation) = 1; 
    15471524          CG(compiled_filename) = file_handle->opened_path; 
     
    26652642 
    26662643#endif  /* #ifdef HAVE_EACCELERATOR */ 
     2644 
     2645/* 
     2646 * Local variables: 
     2647 * tab-width: 2 
     2648 * c-basic-offset: 2 
     2649 * End: 
     2650 * vim600: noet sw=2 ts=2 fdm=marker 
     2651 * vim<600: noet sw=2 ts=2 
     2652 */