Show
Ignore:
Timestamp:
08/20/07 15:15:06 (1 year ago)
Author:
hans
Message:

* Changed crash handler error message format to Apache-style error log format as suggested in ticket #217
* Fixed ticket #274
* Performance: eliminated a bunch of time() syscalls
* Performance: eliminated calls to eaccelerator_gc when not build with either session, shm or user cache functionality (which are all off by default)
* Disable eaccelerator_list_keys function when not build with either session, shm or user cache functionality (which are all off by default)
* Disable 'User Cache' tab in control panel when not build with either session, shm or user cache functionality (which are all off by default)

Files:

Legend:

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

    r328 r330  
     12007-08-20  Hans Rakers <hans at react.nl> 
     2        * Changed crash handler error message format to Apache-style error log 
     3          format as suggested in ticket #217 
     4        * Fixed ticket #274 
     5        * Performance: eliminated a bunch of time() syscalls 
     6        * Performance: eliminated calls to eaccelerator_gc when not build with 
     7          either session, shm or user cache functionality (which are all off 
     8          by default) 
     9        * Disable eaccelerator_list_keys function when not build with either 
     10          session, shm or user cache functionality (which are all off by 
     11          default) 
     12        * Disable 'User Cache' tab in control panel when not build with either 
     13          session, shm or user cache functionality (which are all off by 
     14          default) 
     15 
    1162007-08-20  Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 
    217        * Rewrite the calc_* values so it no longer uses the EAG(mem) global. 
     
    1227 
    1328        * Optimizer fix for #242. PHP-5.2.1 introduces a ZEND_JMP before a 
    14              ZEND_FETCH_CLASS/ZEND_CATCH which the optimizer did not handle 
    15              correctly, resulting in uncaught exceptions. (Thanks to warwickshaw) 
     29          ZEND_FETCH_CLASS/ZEND_CATCH which the optimizer did not handle 
     30          correctly, resulting in uncaught exceptions. (Thanks to warwickshaw) 
    1631 
    17322007-05-09  Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 
  • eaccelerator/trunk/cache.c

    r328 r330  
    249249        memcpy(q->key, xkey, xlen + 1); 
    250250        memcpy(&q->value, val, sizeof(zval)); 
    251         q->ttl = ttl ? time(0) + ttl : 0; 
    252         q->create = time(0); 
     251        q->ttl = ttl ? EAG(req_start) + ttl : 0; 
     252        q->create = EAG(req_start); 
    253253        /* set the refcount to 1 */ 
    254254        q->value.refcount = 1; 
     
    342342            if ((p->hv == hv) && (strcmp(p->key, xkey) == 0)) { 
    343343                x = p; 
    344                 if (p->ttl != 0 && p->ttl < time(0)) { 
     344                if (p->ttl != 0 && p->ttl < EAG(req_start)) { 
    345345                    if (q == NULL) { 
    346346                        eaccelerator_mm_instance->user_hash[slot] = p->next; 
     
    374374    if ((where == ea_shm_and_disk || where == ea_shm || where == ea_disk_only) &&  
    375375            eaccelerator_md5(s, "/eaccelerator-user-", xkey TSRMLS_CC)) { 
    376         time_t t = time(0); 
    377376        int use_shm = 1; 
    378377        int ret = 0; 
     
    391390                return 0; 
    392391            } 
    393             if (hdr.mtime == 0 || hdr.mtime > t) { 
     392            if (hdr.mtime == 0 || hdr.mtime > EAG(req_start)) { 
    394393                /* 
    395394                 * try to put it into shared memory  
     
    549548    return 1; 
    550549} 
    551 #endif 
    552550 
    553551/* do garbage collection on the keys */ 
     
    556554    size_t size = 0; 
    557555    unsigned int i; 
    558     time_t t = time(0); 
     556    time_t t = EAG(req_start); 
    559557 
    560558    if (eaccelerator_mm_instance == NULL) { 
     
    590588    char *xkey = ""; 
    591589    ea_user_cache_entry *p; 
    592     time_t t = time(0); 
    593590 
    594591    // create key prefix for current host / namespace 
     
    623620                 
    624621                if (p->ttl) { 
    625                     if (p->ttl > t) { 
     622                    if (p->ttl > EAG(req_start)) { 
    626623                        add_assoc_long(list, "ttl", p->ttl); // ttl 
    627624                    } else { 
     
    646643#endif /* WITH_EACCELERATOR_INFO */ 
    647644 
     645#endif /* WITH_EACCELERATOR_CONTENT_CACHING) || WITH_EACCELERATOR_SESSIONS || WITH_EACCELERATOR_SHM */ 
     646 
    648647#endif /* HAVE_EACCELERATOR */ 
    649648 
  • eaccelerator/trunk/cache.h

    r286 r330  
    3939int eaccelerator_get (const char *key, int key_len, zval * return_value, ea_cache_place where TSRMLS_DC); 
    4040int eaccelerator_rm (const char *key, int key_len, ea_cache_place where TSRMLS_DC); 
     41size_t eaccelerator_gc (TSRMLS_D); 
    4142#endif 
    42 size_t eaccelerator_gc (TSRMLS_D); 
    4343 
    44  
    45 #ifdef WITH_EACCELERATOR_INFO 
     44#if defined WITH_EACCELERATOR_INFO && (WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 
    4645int eaccelerator_list_keys(zval *return_value TSRMLS_DC); 
    4746#endif 
  • eaccelerator/trunk/control.php

    r326 r330  
    273273<div class="head2"> 
    274274<?php 
    275 $items = array(0 => 'Status', 1 => 'Script Cache', 2 => 'User Cache'); 
     275/* 
     276    Check if eA was compiled with WITH_EACCELERATOR_CONTENT_CACHING) || WITH_EACCELERATOR_SESSIONS || WITH_EACCELERATOR_SHM  
     277    if yes, show 'User Cache' tab, else dont 
     278*/ 
     279if (function_exists(eaccelerator_list_keys)) { 
     280    $items = array(0 => 'Status', 1 => 'Script Cache', 2 => 'User Cache'); 
     281} else { 
     282    $items = array(0 => 'Status', 1 => 'Script Cache'); 
     283
     284 
    276285foreach ($items as $i => $item) { 
    277286    echo '<span class="menuitem'.(($sec == $i)?'_sel':'').'" onmouseover="menusel(this)" onmouseout="menusel(this)" onclick="gosec('.$i.')">'.(($sec != $i)?'<a href="'.$_SERVER['PHP_SELF'].'?sec='.$i.'">'.$item.'</a>':$item).'</span>'; 
  • eaccelerator/trunk/ea_info.c

    r286 r330  
    502502/* }}} */ 
    503503 
     504#if defined (WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 
    504505/* {{{ PHP_FUNCTION(eaccelerator_list_keys): returns list of keys in shared memory that matches actual hostname or namespace */ 
    505506PHP_FUNCTION(eaccelerator_list_keys) 
     
    512513} 
    513514/* }}} */ 
    514  
    515515#endif 
     516 
     517#endif  /* WITH_EACCELERATOR_INFO */ 
    516518 
    517519/* 
  • eaccelerator/trunk/ea_info.h

    r286 r330  
    4141PHP_FUNCTION(eaccelerator_cached_scripts); 
    4242PHP_FUNCTION(eaccelerator_removed_scripts); 
     43#if defined (WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 
    4344PHP_FUNCTION(eaccelerator_list_keys); 
     45#endif 
    4446 
    4547#endif 
  • eaccelerator/trunk/eaccelerator.c

    r309 r330  
    290290  eaccelerator_mm_instance->locks = NULL; 
    291291  eaccelerator_mm_instance->user_hash_cnt = 0; 
    292   eaccelerator_mm_instance->last_prune = time(0); 
     292  eaccelerator_mm_instance->last_prune = time(NULL);   /* this time() call is harmless since this is init phase */ 
    293293  EACCELERATOR_PROTECT(); 
    294294  return SUCCESS; 
     
    463463} 
    464464 
    465 /* Remove expired keys, content and scripts from the cache */ 
     465/* Remove expired keys, content and scripts from the memory cache */ 
    466466void eaccelerator_prune(time_t t) { 
    467467  unsigned int i; 
     
    496496void* eaccelerator_malloc2(size_t size TSRMLS_DC) { 
    497497  void *p = NULL; 
    498   time_t t; 
    499  
     498 
     499#if defined(WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 
    500500  if (eaccelerator_gc(TSRMLS_C) > 0) { 
    501501    p = eaccelerator_malloc(size); 
     
    504504    } 
    505505  } 
     506#endif 
    506507  if (ea_shm_prune_period > 0) { 
    507     t = time(0); 
    508     if (t - eaccelerator_mm_instance->last_prune > ea_shm_prune_period) { 
    509       eaccelerator_prune(t); 
     508    if (EAG(req_start) - eaccelerator_mm_instance->last_prune > ea_shm_prune_period) { 
     509      eaccelerator_prune(EAG(req_start)); 
    510510      p = eaccelerator_malloc(size); 
    511511    } 
     
    740740      p->removed  = 0; 
    741741      if (ea_shm_ttl > 0) { 
    742         p->ttl = time(0) + ea_shm_ttl; 
     742        p->ttl = EAG(req_start) + ea_shm_ttl; 
    743743      } else { 
    744744        p->ttl = 0; 
     
    809809    return 0; 
    810810  } 
    811    
     811 
    812812  DBG(ea_debug_pad, (EA_DEBUG TSRMLS_CC)); 
    813813  DBG(ea_debug_printf, (EA_DEBUG, "[%d] eaccelerator_store:  returned %d, mm=%x\n", getpid(), size, eaccelerator_mm_instance->mm)); 
     
    836836    if (use_shm) { 
    837837      if (ea_shm_ttl > 0) { 
    838         p->ttl = time(0) + ea_shm_ttl; 
     838        p->ttl = EAG(req_start) + ea_shm_ttl; 
    839839      } else { 
    840840        p->ttl = 0; 
     
    11251125#endif 
    11261126 
    1127   compile_time = time(0); 
    11281127  stat_result = eaccelerator_stat(file_handle, realname, &buf TSRMLS_CC); 
    1129   if (buf.st_mtime >= compile_time && eaccelerator_debug > 0) { 
    1130         ea_debug_log("EACCELERATOR: Warning: \"%s\" is cached but it's mtime is in the future.\n", file_handle->filename); 
    1131   } 
    11321128 
    11331129  ok_to_cache = ea_match(EAG(pattern_list), file_handle->filename); 
    1134   
     1130 
    11351131  // eAccelerator isn't working, so just compile the file 
    11361132  if (!EAG(enabled) || (eaccelerator_mm_instance == NULL) ||  
     
    11531149  } 
    11541150 
     1151  compile_time = EAG(req_start); 
     1152  if (buf.st_mtime >= compile_time && eaccelerator_debug > 0) { 
     1153        ea_debug_log("EACCELERATOR: Warning: \"%s\" is cached but it's mtime is in the future.\n", file_handle->filename); 
     1154  } 
     1155 
    11551156  t = eaccelerator_restore(realname, &buf, &nreloads, compile_time TSRMLS_CC); 
    11561157 
     
    11781179    if (file_handle->opened_path == NULL && file_handle->type != ZEND_HANDLE_STREAM) { 
    11791180      file_handle->handle.stream.handle = (void*)1; 
    1180       file_handle->opened_path = EAG(mem); 
     1181      file_handle->opened_path = EAG(mem);      /* EAG(mem) = p->realfilename from eaccelerator_restore here */ 
     1182    } 
    11811183#else 
    11821184    if (file_handle->opened_path == NULL && file_handle->type != ZEND_HANDLE_FP) { 
    11831185      int dummy = 1; 
    1184       file_handle->opened_path = EAG(mem); 
     1186      file_handle->opened_path = EAG(mem);     /* EAG(mem) = p->realfilename from eaccelerator_restore here */ 
    11851187      zend_hash_add(&EG(included_files), file_handle->opened_path, strlen(file_handle->opened_path)+1, (void *)&dummy, sizeof(int), NULL); 
    11861188      file_handle->handle.fp = NULL; 
    1187 #endif 
    1188     } 
     1189    } 
     1190#endif 
     1191 
    11891192    DBG(ea_debug_printf, (EA_TEST_PERFORMANCE, "\t[%d] compile_file: restored (%ld)\n", getpid(), ea_debug_elapsed_time(&tv_start))); 
    11901193    DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] compile_file: restored\n", getpid())); 
     
    11931196#endif 
    11941197    DBG(ea_debug_printf, (EA_DEBUG, "[%d] Leave COMPILE\n", getpid())); 
     1198 
    11951199    return t; 
     1200 
    11961201  } else { // not in cache or must be recompiled 
    11971202                Bucket *function_table_tail; 
     
    12671272    if (t != NULL && file_handle->opened_path != NULL && (eaccelerator_check_mtime || 
    12681273         ((stat(file_handle->opened_path, &buf) == 0) && S_ISREG(buf.st_mode)))) { 
     1274 
    12691275      DBG(ea_debug_printf, (EA_TEST_PERFORMANCE, "\t[%d] compile_file: storing in cache (%ld)\n", getpid(), ea_debug_elapsed_time(&tv_start))); 
    12701276      DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] compile_file: storing in cache\n", getpid())); 
    12711277      function_table_tail = function_table_tail ? function_table_tail->pListNext : CG(function_table)->pListHead; 
    12721278      class_table_tail = class_table_tail ? class_table_tail->pListNext : CG(class_table)->pListHead; 
     1279 
    12731280      if (eaccelerator_store(file_handle->opened_path, &buf, nreloads, t, function_table_tail, class_table_tail TSRMLS_CC)) { 
    12741281#ifdef DEBUG 
     
    16471654#ifdef WITH_EACCELERATOR_CRASH_DETECTION 
    16481655static void eaccelerator_crash_handler(int dummy) { 
     1656  struct tm *loctime; 
     1657 
    16491658  TSRMLS_FETCH(); 
    16501659  fflush(stdout); 
     
    16861695#endif 
    16871696  eaccelerator_clean_request(TSRMLS_C); 
     1697 
     1698  loctime = localtime(&EAG(req_start)); 
     1699 
    16881700  if (EG(active_op_array)) { 
    1689     fprintf(stderr, "[%d] EACCELERATOR: PHP crashed on opline %ld of %s() at %s:%u\n\n", 
     1701    fprintf(stderr, "[%s] [notice] EACCELERATOR(%d): PHP crashed on opline %ld of %s() at %s:%u\n\n", 
     1702      asctime(loctime), 
    16901703      getpid(), 
    16911704      (long)(active_opline-EG(active_op_array)->opcodes), 
     
    16941707      zend_get_executed_lineno(TSRMLS_C)); 
    16951708  } else { 
    1696     fprintf(stderr, "[%d] EACCELERATOR: PHP crashed\n\n",getpid()); 
     1709    fprintf(stderr, "[%s] [notice] EACCELERATOR(%d): PHP crashed\n\n", asctime(loctime), getpid()); 
    16971710  } 
    16981711#if !defined(WIN32) && !defined(NETWARE) 
     
    17171730        eag->eaccelerator_log_file = '\000'; 
    17181731        eag->name_space = '\000'; 
     1732#if defined(WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 
    17191733        eag->hostname[0] = '\000'; 
     1734#endif 
    17201735        eag->in_request = 0; 
    17211736        eag->allowed_admin_path= NULL; 
     
    18851900PHP_RINIT_FUNCTION(eaccelerator) 
    18861901{ 
     1902#if defined(WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 
    18871903  union { 
    18881904                zval **v; 
    18891905    void *ptr; 
    18901906  } server_vars, hostname; 
     1907#endif 
    18911908 
    18921909        if (eaccelerator_mm_instance == NULL) { 
     
    19031920        EAG(compress_content) = 1; 
    19041921        EAG(content_headers) = NULL; 
    1905  
     1922        EAG(req_start) = time(NULL);    /* record request start time for later use */ 
     1923 
     1924#if defined(WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 
    19061925        /* Storing Host Name */ 
    19071926        EAG(hostname)[0] = '\000'; 
     
    19171936                } 
    19181937  } 
     1938#endif 
    19191939 
    19201940        zend_hash_init(&EAG(restored), 0, NULL, NULL, 0); 
    19211941 
    1922         DBG(ea_debug_printf, (EA_DEBUG, "[%d] Leave RINIT\n",getpid())); 
    19231942#ifdef DEBUG 
    19241943        EAG(xpad) = 0; 
     
    19431962#endif 
    19441963#endif 
     1964 
     1965        DBG(ea_debug_printf, (EA_DEBUG, "[%d] Leave RINIT\n",getpid())); 
     1966         
    19451967        return SUCCESS; 
    19461968} 
     
    20242046  PHP_FE(eaccelerator_cached_scripts, NULL) 
    20252047  PHP_FE(eaccelerator_removed_scripts, NULL) 
     2048#  if defined(WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 
    20262049  PHP_FE(eaccelerator_list_keys, NULL) 
     2050#  endif 
    20272051#endif 
    20282052#ifdef WITH_EACCELERATOR_CONTENT_CACHING 
  • eaccelerator/trunk/eaccelerator.h

    r329 r330  
    439439 */ 
    440440ZEND_BEGIN_MODULE_GLOBALS (eaccelerator) 
    441 void *used_entries;                            /* list of files which are used     */ 
    442                                                                /* by process/thread                */ 
     441void *used_entries;                     /* list of files which are used     */ 
     442                                        /* by process/thread                */ 
    443443zend_bool enabled; 
    444444zend_bool optimizer_enabled; 
     
    455455char *mem; 
    456456char *allowed_admin_path; 
     457time_t req_start;                       /* time of request start (set in RINIT) */ 
    457458HashTable strings; 
    458459HashTable restored; 
    459460zend_class_entry *class_entry; 
    460461zend_uint refcount_helper; 
     462#if defined(WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 
    461463char hostname[32]; 
     464#endif 
    462465struct ea_pattern_t *pattern_list; 
    463466#ifdef WITH_EACCELERATOR_CRASH_DETECTION