Changeset 330
- Timestamp:
- 08/20/07 15:15:06 (9 months ago)
- Files:
-
- eaccelerator/trunk/ChangeLog (modified) (2 diffs)
- eaccelerator/trunk/cache.c (modified) (9 diffs)
- eaccelerator/trunk/cache.h (modified) (1 diff)
- eaccelerator/trunk/control.php (modified) (1 diff)
- eaccelerator/trunk/ea_info.c (modified) (2 diffs)
- eaccelerator/trunk/ea_info.h (modified) (1 diff)
- eaccelerator/trunk/eaccelerator.c (modified) (21 diffs)
- eaccelerator/trunk/eaccelerator.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
eaccelerator/trunk/ChangeLog
r328 r330 1 2007-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 1 16 2007-08-20 Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 2 17 * Rewrite the calc_* values so it no longer uses the EAG(mem) global. … … 12 27 13 28 * 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 handle15 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) 16 31 17 32 2007-05-09 Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> eaccelerator/trunk/cache.c
r328 r330 249 249 memcpy(q->key, xkey, xlen + 1); 250 250 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); 253 253 /* set the refcount to 1 */ 254 254 q->value.refcount = 1; … … 342 342 if ((p->hv == hv) && (strcmp(p->key, xkey) == 0)) { 343 343 x = p; 344 if (p->ttl != 0 && p->ttl < time(0)) {344 if (p->ttl != 0 && p->ttl < EAG(req_start)) { 345 345 if (q == NULL) { 346 346 eaccelerator_mm_instance->user_hash[slot] = p->next; … … 374 374 if ((where == ea_shm_and_disk || where == ea_shm || where == ea_disk_only) && 375 375 eaccelerator_md5(s, "/eaccelerator-user-", xkey TSRMLS_CC)) { 376 time_t t = time(0);377 376 int use_shm = 1; 378 377 int ret = 0; … … 391 390 return 0; 392 391 } 393 if (hdr.mtime == 0 || hdr.mtime > t) {392 if (hdr.mtime == 0 || hdr.mtime > EAG(req_start)) { 394 393 /* 395 394 * try to put it into shared memory … … 549 548 return 1; 550 549 } 551 #endif552 550 553 551 /* do garbage collection on the keys */ … … 556 554 size_t size = 0; 557 555 unsigned int i; 558 time_t t = time(0);556 time_t t = EAG(req_start); 559 557 560 558 if (eaccelerator_mm_instance == NULL) { … … 590 588 char *xkey = ""; 591 589 ea_user_cache_entry *p; 592 time_t t = time(0);593 590 594 591 // create key prefix for current host / namespace … … 623 620 624 621 if (p->ttl) { 625 if (p->ttl > t) {622 if (p->ttl > EAG(req_start)) { 626 623 add_assoc_long(list, "ttl", p->ttl); // ttl 627 624 } else { … … 646 643 #endif /* WITH_EACCELERATOR_INFO */ 647 644 645 #endif /* WITH_EACCELERATOR_CONTENT_CACHING) || WITH_EACCELERATOR_SESSIONS || WITH_EACCELERATOR_SHM */ 646 648 647 #endif /* HAVE_EACCELERATOR */ 649 648 eaccelerator/trunk/cache.h
r286 r330 39 39 int eaccelerator_get (const char *key, int key_len, zval * return_value, ea_cache_place where TSRMLS_DC); 40 40 int eaccelerator_rm (const char *key, int key_len, ea_cache_place where TSRMLS_DC); 41 size_t eaccelerator_gc (TSRMLS_D); 41 42 #endif 42 size_t eaccelerator_gc (TSRMLS_D);43 43 44 45 #ifdef WITH_EACCELERATOR_INFO 44 #if defined WITH_EACCELERATOR_INFO && (WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 46 45 int eaccelerator_list_keys(zval *return_value TSRMLS_DC); 47 46 #endif eaccelerator/trunk/control.php
r326 r330 273 273 <div class="head2"> 274 274 <?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 */ 279 if (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 276 285 foreach ($items as $i => $item) { 277 286 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 502 502 /* }}} */ 503 503 504 #if defined (WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 504 505 /* {{{ PHP_FUNCTION(eaccelerator_list_keys): returns list of keys in shared memory that matches actual hostname or namespace */ 505 506 PHP_FUNCTION(eaccelerator_list_keys) … … 512 513 } 513 514 /* }}} */ 514 515 515 #endif 516 517 #endif /* WITH_EACCELERATOR_INFO */ 516 518 517 519 /* eaccelerator/trunk/ea_info.h
r286 r330 41 41 PHP_FUNCTION(eaccelerator_cached_scripts); 42 42 PHP_FUNCTION(eaccelerator_removed_scripts); 43 #if defined (WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 43 44 PHP_FUNCTION(eaccelerator_list_keys); 45 #endif 44 46 45 47 #endif eaccelerator/trunk/eaccelerator.c
r309 r330 290 290 eaccelerator_mm_instance->locks = NULL; 291 291 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 */ 293 293 EACCELERATOR_PROTECT(); 294 294 return SUCCESS; … … 463 463 } 464 464 465 /* Remove expired keys, content and scripts from the cache */465 /* Remove expired keys, content and scripts from the memory cache */ 466 466 void eaccelerator_prune(time_t t) { 467 467 unsigned int i; … … 496 496 void* eaccelerator_malloc2(size_t size TSRMLS_DC) { 497 497 void *p = NULL; 498 time_t t; 499 498 499 #if defined(WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 500 500 if (eaccelerator_gc(TSRMLS_C) > 0) { 501 501 p = eaccelerator_malloc(size); … … 504 504 } 505 505 } 506 #endif 506 507 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)); 510 510 p = eaccelerator_malloc(size); 511 511 } … … 740 740 p->removed = 0; 741 741 if (ea_shm_ttl > 0) { 742 p->ttl = time(0) + ea_shm_ttl;742 p->ttl = EAG(req_start) + ea_shm_ttl; 743 743 } else { 744 744 p->ttl = 0; … … 809 809 return 0; 810 810 } 811 811 812 812 DBG(ea_debug_pad, (EA_DEBUG TSRMLS_CC)); 813 813 DBG(ea_debug_printf, (EA_DEBUG, "[%d] eaccelerator_store: returned %d, mm=%x\n", getpid(), size, eaccelerator_mm_instance->mm)); … … 836 836 if (use_shm) { 837 837 if (ea_shm_ttl > 0) { 838 p->ttl = time(0) + ea_shm_ttl;838 p->ttl = EAG(req_start) + ea_shm_ttl; 839 839 } else { 840 840 p->ttl = 0; … … 1125 1125 #endif 1126 1126 1127 compile_time = time(0);1128 1127 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 }1132 1128 1133 1129 ok_to_cache = ea_match(EAG(pattern_list), file_handle->filename); 1134 1130 1135 1131 // eAccelerator isn't working, so just compile the file 1136 1132 if (!EAG(enabled) || (eaccelerator_mm_instance == NULL) || … … 1153 1149 } 1154 1150 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 1155 1156 t = eaccelerator_restore(realname, &buf, &nreloads, compile_time TSRMLS_CC); 1156 1157 … … 1178 1179 if (file_handle->opened_path == NULL && file_handle->type != ZEND_HANDLE_STREAM) { 1179 1180 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 } 1181 1183 #else 1182 1184 if (file_handle->opened_path == NULL && file_handle->type != ZEND_HANDLE_FP) { 1183 1185 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 */ 1185 1187 zend_hash_add(&EG(included_files), file_handle->opened_path, strlen(file_handle->opened_path)+1, (void *)&dummy, sizeof(int), NULL); 1186 1188 file_handle->handle.fp = NULL; 1187 #endif 1188 } 1189 } 1190 #endif 1191 1189 1192 DBG(ea_debug_printf, (EA_TEST_PERFORMANCE, "\t[%d] compile_file: restored (%ld)\n", getpid(), ea_debug_elapsed_time(&tv_start))); 1190 1193 DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] compile_file: restored\n", getpid())); … … 1193 1196 #endif 1194 1197 DBG(ea_debug_printf, (EA_DEBUG, "[%d] Leave COMPILE\n", getpid())); 1198 1195 1199 return t; 1200 1196 1201 } else { // not in cache or must be recompiled 1197 1202 Bucket *function_table_tail; … … 1267 1272 if (t != NULL && file_handle->opened_path != NULL && (eaccelerator_check_mtime || 1268 1273 ((stat(file_handle->opened_path, &buf) == 0) && S_ISREG(buf.st_mode)))) { 1274 1269 1275 DBG(ea_debug_printf, (EA_TEST_PERFORMANCE, "\t[%d] compile_file: storing in cache (%ld)\n", getpid(), ea_debug_elapsed_time(&tv_start))); 1270 1276 DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] compile_file: storing in cache\n", getpid())); 1271 1277 function_table_tail = function_table_tail ? function_table_tail->pListNext : CG(function_table)->pListHead; 1272 1278 class_table_tail = class_table_tail ? class_table_tail->pListNext : CG(class_table)->pListHead; 1279 1273 1280 if (eaccelerator_store(file_handle->opened_path, &buf, nreloads, t, function_table_tail, class_table_tail TSRMLS_CC)) { 1274 1281 #ifdef DEBUG … … 1647 1654 #ifdef WITH_EACCELERATOR_CRASH_DETECTION 1648 1655 static void eaccelerator_crash_handler(int dummy) { 1656 struct tm *loctime; 1657 1649 1658 TSRMLS_FETCH(); 1650 1659 fflush(stdout); … … 1686 1695 #endif 1687 1696 eaccelerator_clean_request(TSRMLS_C); 1697 1698 loctime = localtime(&EAG(req_start)); 1699 1688 1700 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), 1690 1703 getpid(), 1691 1704 (long)(active_opline-EG(active_op_array)->opcodes), … … 1694 1707 zend_get_executed_lineno(TSRMLS_C)); 1695 1708 } 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()); 1697 1710 } 1698 1711 #if !defined(WIN32) && !defined(NETWARE) … … 1717 1730 eag->eaccelerator_log_file = '\000'; 1718 1731 eag->name_space = '\000'; 1732 #if defined(WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 1719 1733 eag->hostname[0] = '\000'; 1734 #endif 1720 1735 eag->in_request = 0; 1721 1736 eag->allowed_admin_path= NULL; … … 1885 1900 PHP_RINIT_FUNCTION(eaccelerator) 1886 1901 { 1902 #if defined(WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 1887 1903 union { 1888 1904 zval **v; 1889 1905 void *ptr; 1890 1906 } server_vars, hostname; 1907 #endif 1891 1908 1892 1909 if (eaccelerator_mm_instance == NULL) { … … 1903 1920 EAG(compress_content) = 1; 1904 1921 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) 1906 1925 /* Storing Host Name */ 1907 1926 EAG(hostname)[0] = '\000'; … … 1917 1936 } 1918 1937 } 1938 #endif 1919 1939 1920 1940 zend_hash_init(&EAG(restored), 0, NULL, NULL, 0); 1921 1941 1922 DBG(ea_debug_printf, (EA_DEBUG, "[%d] Leave RINIT\n",getpid()));1923 1942 #ifdef DEBUG 1924 1943 EAG(xpad) = 0; … … 1943 1962 #endif 1944 1963 #endif 1964 1965 DBG(ea_debug_printf, (EA_DEBUG, "[%d] Leave RINIT\n",getpid())); 1966 1945 1967 return SUCCESS; 1946 1968 } … … 2024 2046 PHP_FE(eaccelerator_cached_scripts, NULL) 2025 2047 PHP_FE(eaccelerator_removed_scripts, NULL) 2048 # if defined(WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 2026 2049 PHP_FE(eaccelerator_list_keys, NULL) 2050 # endif 2027 2051 #endif 2028 2052 #ifdef WITH_EACCELERATOR_CONTENT_CACHING eaccelerator/trunk/eaccelerator.h
r329 r330 439 439 */ 440 440 ZEND_BEGIN_MODULE_GLOBALS (eaccelerator) 441 void *used_entries; /* list of files which are used */442 /* by process/thread */441 void *used_entries; /* list of files which are used */ 442 /* by process/thread */ 443 443 zend_bool enabled; 444 444 zend_bool optimizer_enabled; … … 455 455 char *mem; 456 456 char *allowed_admin_path; 457 time_t req_start; /* time of request start (set in RINIT) */ 457 458 HashTable strings; 458 459 HashTable restored; 459 460 zend_class_entry *class_entry; 460 461 zend_uint refcount_helper; 462 #if defined(WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 461 463 char hostname[32]; 464 #endif 462 465 struct ea_pattern_t *pattern_list; 463 466 #ifdef WITH_EACCELERATOR_CRASH_DETECTION