Changeset 254
- Timestamp:
- 07/29/06 12:37:52 (2 years ago)
- Files:
-
- eaccelerator/trunk/ChangeLog (modified) (1 diff)
- eaccelerator/trunk/cache.c (modified) (27 diffs)
- eaccelerator/trunk/cache.h (modified) (1 diff)
- eaccelerator/trunk/content.c (modified) (8 diffs)
- eaccelerator/trunk/ea_dasm.c (modified) (6 diffs)
- eaccelerator/trunk/ea_info.c (modified) (7 diffs)
- eaccelerator/trunk/ea_restore.c (modified) (10 diffs)
- eaccelerator/trunk/ea_restore.h (modified) (1 diff)
- eaccelerator/trunk/ea_store.c (modified) (7 diffs)
- eaccelerator/trunk/ea_store.h (modified) (1 diff)
- eaccelerator/trunk/eaccelerator.c (modified) (33 diffs)
- eaccelerator/trunk/eaccelerator.h (modified) (12 diffs)
- eaccelerator/trunk/session.c (modified) (4 diffs)
- eaccelerator/trunk/shm.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
eaccelerator/trunk/ChangeLog
r253 r254 4 4 faster and provides a much better distribution. 5 5 * Don't compile the user cache code one no feature is being compiled. 6 * A big cleanup in struct naming 6 7 7 8 2006-07-29 Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> eaccelerator/trunk/cache.c
r253 r254 29 29 #include "eaccelerator_version.h" 30 30 31 #if defined(HAVE_EACCELERATOR) && (defined(WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM))31 #ifdef HAVE_EACCELERATOR 32 32 33 33 #include "zend.h" … … 44 44 45 45 /* variables needed from eaccelerator.c */ 46 extern long ea ccelerator_shm_max;46 extern long ea_shm_max; 47 47 extern eaccelerator_mm *eaccelerator_mm_instance; 48 48 extern int binary_eaccelerator_version; 49 49 extern int binary_php_version; 50 50 extern int binary_zend_version; 51 52 #if defined(WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 51 53 52 54 static char *build_key(const char *key, int key_len, int *xlen TSRMLS_DC) … … 91 93 int xlen; 92 94 char *xkey; 93 mm_lock_entry *x;94 mm_lock_entry **p;95 ea_lock_entry *x; 96 ea_lock_entry **p; 95 97 int ok = 0; 96 98 … … 100 102 xkey = build_key(key, key_len, &xlen TSRMLS_CC); 101 103 EACCELERATOR_UNPROTECT(); 102 x = eaccelerator_malloc(offsetof( mm_lock_entry, key) + xlen + 1);104 x = eaccelerator_malloc(offsetof(ea_lock_entry, key) + xlen + 1); 103 105 if (x == NULL) { 104 106 EACCELERATOR_PROTECT(); … … 161 163 int xlen; 162 164 char *xkey; 163 mm_lock_entry **p;165 ea_lock_entry **p; 164 166 165 167 if (eaccelerator_mm_instance == NULL) … … 177 179 if ((*p)->pid == getpid()) { 178 180 #endif 179 mm_lock_entry *x = (*p);181 ea_lock_entry *x = (*p); 180 182 *p = (*p)->next; 181 183 eaccelerator_free_nolock(x); … … 201 203 202 204 /* put a key in the cache (shm or disk) */ 203 int eaccelerator_put(const char *key, int key_len, zval * val, time_t ttl, 204 eaccelerator_cache_place where TSRMLS_DC) 205 { 206 mm_user_cache_entry *p, *q; 205 int eaccelerator_put(const char *key, int key_len, zval * val, time_t ttl, ea_cache_place where TSRMLS_DC) 206 { 207 ea_user_cache_entry *p, *q; 207 208 unsigned int slot, hv; 208 209 long size; … … 218 219 zend_hash_init(&EAG(strings), 0, NULL, NULL, 0); 219 220 EACCELERATOR_ALIGN(EAG(mem)); 220 EAG(mem) += offsetof( mm_user_cache_entry, key) + xlen + 1;221 EAG(mem) += offsetof(ea_user_cache_entry, key) + xlen + 1; 221 222 calc_zval(val TSRMLS_CC); 222 223 zend_hash_destroy(&EAG(strings)); … … 225 226 226 227 EAG(mem) = NULL; 227 if (eaccelerator_mm_instance != NULL && (where == eaccelerator_shm_and_disk || 228 where == eaccelerator_shm || where == eaccelerator_shm_only)) { 228 if (eaccelerator_mm_instance != NULL && (where == ea_shm_and_disk || where == ea_shm || where == ea_shm_only)) { 229 229 EACCELERATOR_UNPROTECT(); 230 if (ea ccelerator_shm_max == 0 || size <= eaccelerator_shm_max) {230 if (ea_shm_max == 0 || size <= ea_shm_max) { 231 231 EAG(mem) = eaccelerator_malloc(size); 232 232 if (EAG(mem) == NULL) { … … 238 238 } 239 239 } 240 if (EAG(mem) == NULL && (where == eaccelerator_shm_and_disk || 241 where == eaccelerator_shm || where == eaccelerator_disk_only)) { 240 if (EAG(mem) == NULL && (where == ea_shm_and_disk || where == ea_shm || where == ea_disk_only)) { 242 241 use_shm = 0; 243 242 EAG(mem) = emalloc(size); … … 246 245 zend_hash_init(&EAG(strings), 0, NULL, NULL, 0); 247 246 EACCELERATOR_ALIGN(EAG(mem)); 248 q = ( mm_user_cache_entry *) EAG(mem);247 q = (ea_user_cache_entry *) EAG(mem); 249 248 q->size = size; 250 EAG(mem) += offsetof( mm_user_cache_entry, key) + xlen + 1;249 EAG(mem) += offsetof(ea_user_cache_entry, key) + xlen + 1; 251 250 q->hv = zend_get_hash_value(xkey, xlen); 252 251 memcpy(q->key, xkey, xlen + 1); … … 262 261 * storing to file 263 262 */ 264 if ((where == ea ccelerator_shm_and_disk || ((where == eaccelerator_shm) && !use_shm) ||265 where == eaccelerator_disk_only) &&eaccelerator_md5(s, "/eaccelerator-user-", q->key TSRMLS_CC)) {263 if ((where == ea_shm_and_disk || ((where == ea_shm) && !use_shm) || where == ea_disk_only) && 264 eaccelerator_md5(s, "/eaccelerator-user-", q->key TSRMLS_CC)) { 266 265 int f; 267 266 unlink(s); 268 267 f = open(s, O_CREAT | O_WRONLY | O_EXCL | O_BINARY, S_IRUSR | S_IWUSR); 269 268 if (f > 0) { 270 mm_file_header hdr;269 ea_file_header hdr; 271 270 EACCELERATOR_FLOCK(f, LOCK_EX); 272 271 strncpy(hdr.magic, EA_MAGIC, 8); … … 294 293 } 295 294 296 if ((where == ea ccelerator_shm_and_disk || where == eaccelerator_shm || where == eaccelerator_shm_only) && use_shm) {295 if ((where == ea_shm_and_disk || where == ea_shm || where == ea_shm_only) && use_shm) { 297 296 /* 298 297 * storing to shared memory … … 327 326 328 327 /* get a key from the cache */ 329 int eaccelerator_get(const char *key, int key_len, zval * return_value, 330 eaccelerator_cache_place where TSRMLS_DC) 328 int eaccelerator_get(const char *key, int key_len, zval * return_value, ea_cache_place where TSRMLS_DC) 331 329 { 332 330 unsigned int hv, slot; … … 339 337 slot = hv & EA_USER_HASH_MAX; 340 338 341 if (eaccelerator_mm_instance != NULL && (where == eaccelerator_shm_and_disk 342 || where == eaccelerator_shm || where == eaccelerator_shm_only)) { 343 mm_user_cache_entry *p, *q; 344 mm_user_cache_entry *x = NULL; 339 if (eaccelerator_mm_instance != NULL && (where == ea_shm_and_disk || where == ea_shm || where == ea_shm_only)) { 340 ea_user_cache_entry *p, *q; 341 ea_user_cache_entry *x = NULL; 345 342 EACCELERATOR_UNPROTECT(); 346 343 EACCELERATOR_LOCK_RW(); … … 380 377 * key is not found in shared memory try to load it from file 381 378 */ 382 if ((where == eaccelerator_shm_and_disk || where == eaccelerator_shm || 383 where == eaccelerator_disk_only) && 379 if ((where == ea_shm_and_disk || where == ea_shm || where == ea_disk_only) && 384 380 eaccelerator_md5(s, "/eaccelerator-user-", xkey TSRMLS_CC)) { 385 381 time_t t = time(0); … … 389 385 390 386 if ((f = open(s, O_RDONLY | O_BINARY)) > 0) { 391 mm_file_header hdr;387 ea_file_header hdr; 392 388 393 389 EACCELERATOR_FLOCK(f, LOCK_SH); … … 406 402 * try to put it into shared memory 407 403 */ 408 mm_user_cache_entry *p = NULL;409 if (eaccelerator_mm_instance != NULL && (where == ea ccelerator_shm_and_disk || where == eaccelerator_shm)) {410 if (ea ccelerator_shm_max == 0 || hdr.size <= eaccelerator_shm_max) {404 ea_user_cache_entry *p = NULL; 405 if (eaccelerator_mm_instance != NULL && (where == ea_shm_and_disk || where == ea_shm)) { 406 if (ea_shm_max == 0 || hdr.size <= ea_shm_max) { 411 407 EACCELERATOR_UNPROTECT(); 412 408 p = eaccelerator_malloc(hdr.size); … … 453 449 if (use_shm) { 454 450 /* put it into shared memory */ 455 mm_user_cache_entry *q, *prev;451 ea_user_cache_entry *q, *prev; 456 452 457 453 p->hv = hv; … … 509 505 510 506 /* remove a key from the cache */ 511 int eaccelerator_rm(const char *key, int key_len, 512 eaccelerator_cache_place where TSRMLS_DC) 507 int eaccelerator_rm(const char *key, int key_len, ea_cache_place where TSRMLS_DC) 513 508 { 514 509 unsigned int hv, slot; 515 mm_user_cache_entry *p, *q;510 ea_user_cache_entry *p, *q; 516 511 char s[MAXPATHLEN]; 517 512 int xlen; … … 522 517 * removing file 523 518 */ 524 if ((where == ea ccelerator_shm_and_disk || where == eaccelerator_shm ||525 where == eaccelerator_disk_only) &&eaccelerator_md5(s, "/eaccelerator-user-", xkey TSRMLS_CC)) {519 if ((where == ea_shm_and_disk || where == ea_shm || where == ea_disk_only) && 520 eaccelerator_md5(s, "/eaccelerator-user-", xkey TSRMLS_CC)) { 526 521 unlink(s); 527 522 } … … 530 525 * removing from shared memory 531 526 */ 532 if (eaccelerator_mm_instance != NULL && (where == ea ccelerator_shm_and_disk ||533 where == ea ccelerator_shm || where == eaccelerator_shm_only)) {527 if (eaccelerator_mm_instance != NULL && (where == ea_shm_and_disk || 528 where == ea_shm || where == ea_shm_only)) { 534 529 hv = zend_get_hash_value(xkey, xlen); 535 530 slot = hv & EA_USER_HASH_MAX; … … 561 556 return 1; 562 557 } 558 #endif 563 559 564 560 /* do garbage collection on the keys */ … … 575 571 EACCELERATOR_LOCK_RW(); 576 572 for (i = 0; i < EA_USER_HASH_SIZE; i++) { 577 mm_user_cache_entry **p = &eaccelerator_mm_instance->user_hash[i];573 ea_user_cache_entry **p = &eaccelerator_mm_instance->user_hash[i]; 578 574 while (*p != NULL) { 579 575 if ((*p)->ttl != 0 && (*p)->ttl < t) { 580 mm_user_cache_entry *r = *p;576 ea_user_cache_entry *r = *p; 581 577 *p = (*p)->next; 582 578 eaccelerator_mm_instance->user_hash_cnt--; … … 593 589 } 594 590 591 #ifdef WITH_EACCELERATOR_INFO 595 592 /* get list of all keys stored in memory that matches hostname or namespace */ 596 593 int eaccelerator_list_keys(zval *return_value TSRMLS_DC) … … 599 596 zval *list; 600 597 char *xkey = ""; 601 mm_user_cache_entry *p;598 ea_user_cache_entry *p; 602 599 time_t t = time(0); 603 600 … … 654 651 return 1; 655 652 } 653 #endif /* WITH_EACCELERATOR_INFO */ 656 654 657 655 #endif /* HAVE_EACCELERATOR */ eaccelerator/trunk/cache.h
r182 r254 35 35 #include "zend_extensions.h" 36 36 37 int eaccelerator_put (const char *key, int key_len, zval * val, time_t ttl, 38 eaccelerator_cache_place where TSRMLS_DC); 39 int eaccelerator_get (const char *key, int key_len, zval * return_value, 40 eaccelerator_cache_place where TSRMLS_DC); 41 int eaccelerator_rm (const char *key, int key_len, 42 eaccelerator_cache_place where TSRMLS_DC); 37 #if defined(WITH_EACCELERATOR_CONTENT_CACHING) || defined(WITH_EACCELERATOR_SESSIONS) || defined(WITH_EACCELERATOR_SHM) 38 int eaccelerator_put (const char *key, int key_len, zval * val, time_t ttl, ea_cache_place where TSRMLS_DC); 39 int eaccelerator_get (const char *key, int key_len, zval * return_value, ea_cache_place where TSRMLS_DC); 40 int eaccelerator_rm (const char *key, int key_len, ea_cache_place where TSRMLS_DC); 41 #endif 43 42 size_t eaccelerator_gc (TSRMLS_D); 44 43 44 45 #ifdef WITH_EACCELERATOR_INFO 45 46 int eaccelerator_list_keys(zval *return_value TSRMLS_DC); 47 #endif 46 48 47 49 #endif /* INCLUDED_CACHE_H */ eaccelerator/trunk/content.c
r228 r254 37 37 #define EACCELERATOR_COMPRESS_MIN 128 38 38 39 ea ccelerator_cache_place eaccelerator_content_cache_place = eaccelerator_shm_and_disk;39 ea_cache_place eaccelerator_content_cache_place = ea_shm_and_disk; 40 40 41 41 static int (*eaccelerator_old_header_handler)(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC); 42 42 43 PHP_INI_MH (eaccelerator_OnUpdateContentCachePlace)43 PHP_INI_MH(eaccelerator_OnUpdateContentCachePlace) 44 44 { 45 if (strncasecmp ("shm_and_disk", new_value, 46 sizeof ("shm_and_disk")) == 0) 47 { 48 eaccelerator_content_cache_place = eaccelerator_shm_and_disk; 49 } 50 else if (strncasecmp ("shm", new_value, 51 sizeof ("shm")) == 0) 52 { 53 eaccelerator_content_cache_place = eaccelerator_shm; 54 } 55 else if (strncasecmp ("shm_only", new_value, 56 sizeof ("shm_only")) == 0) 57 { 58 eaccelerator_content_cache_place = eaccelerator_shm_only; 59 } 60 else if (strncasecmp ("disk_only", new_value, 61 sizeof ("disk_only")) == 0) 62 { 63 eaccelerator_content_cache_place = eaccelerator_disk_only; 64 } 65 else if (strncasecmp ("none", new_value, 66 sizeof ("none")) == 0) 67 { 68 eaccelerator_content_cache_place = eaccelerator_none; 45 if (strncasecmp("shm_and_disk", new_value, sizeof("shm_and_disk")) == 0) { 46 eaccelerator_content_cache_place = ea_shm_and_disk; 47 } else if (strncasecmp("shm", new_value, sizeof("shm")) == 0) { 48 eaccelerator_content_cache_place = ea_shm; 49 } else if (strncasecmp("shm_only", new_value, sizeof("shm_only")) == 0) { 50 eaccelerator_content_cache_place = ea_shm_only; 51 } else if (strncasecmp("disk_only", new_value, sizeof("disk_only")) == 0) { 52 eaccelerator_content_cache_place = ea_disk_only; 53 } else if (strncasecmp("none", new_value, sizeof("none")) == 0) { 54 eaccelerator_content_cache_place = ea_none; 69 55 } 70 56 return SUCCESS; … … 108 94 109 95 void eaccelerator_content_cache_startup() { 110 if (eaccelerator_content_cache_place != ea ccelerator_none) {96 if (eaccelerator_content_cache_place != ea_none) { 111 97 eaccelerator_old_header_handler = sapi_module.header_handler; 112 98 sapi_module.header_handler = eaccelerator_header_handler; … … 115 101 116 102 void eaccelerator_content_cache_shutdown() { 117 if (eaccelerator_content_cache_place != ea ccelerator_none) {103 if (eaccelerator_content_cache_place != ea_none) { 118 104 sapi_module.header_handler = eaccelerator_old_header_handler; 119 105 } … … 397 383 RETURN_FALSE; 398 384 } 399 if (eaccelerator_content_cache_place == ea ccelerator_none) {385 if (eaccelerator_content_cache_place == ea_none) { 400 386 RETURN_FALSE; 401 387 } … … 512 498 return; 513 499 } 514 if (eaccelerator_content_cache_place == ea ccelerator_none) {500 if (eaccelerator_content_cache_place == ea_none) { 515 501 RETURN_NULL(); 516 502 } … … 541 527 return; 542 528 } 543 if (eaccelerator_content_cache_place == ea ccelerator_none) {529 if (eaccelerator_content_cache_place == ea_none) { 544 530 eval_name = zend_make_compiled_string_description("eval()'d code" TSRMLS_CC); 545 531 zend_eval_string(code, NULL, eval_name TSRMLS_CC); … … 593 579 return; 594 580 } 595 if ((eaccelerator_content_cache_place != ea ccelerator_none) &&581 if ((eaccelerator_content_cache_place != ea_none) && 596 582 eaccelerator_get(key, key_len, return_value, eaccelerator_content_cache_place TSRMLS_CC)) { 597 583 /* Return value is cached. Return it. */ … … 601 587 eval_name = zend_make_compiled_string_description("eval()'d code" TSRMLS_CC); 602 588 if (zend_eval_string(code, return_value, eval_name TSRMLS_CC) == SUCCESS && 603 eaccelerator_content_cache_place != ea ccelerator_none) {589 eaccelerator_content_cache_place != ea_none) { 604 590 605 591 #ifndef ZEND_ENGINE_2_1 eaccelerator/trunk/ea_dasm.c
r229 r254 197 197 * } 198 198 */ 199 static zval *get_op_array(ea ccelerator_op_array *op_array TSRMLS_DC)199 static zval *get_op_array(ea_op_array *op_array TSRMLS_DC) 200 200 { 201 201 zval *return_value; … … 505 505 506 506 /* {{{ get_cache_entry: get the cache_entry for the given file */ 507 static mm_cache_entry *get_cache_entry(const char *file) {507 static ea_cache_entry *get_cache_entry(const char *file) { 508 508 unsigned int slot; 509 mm_cache_entry *p;510 mm_cache_entry *result = NULL;509 ea_cache_entry *p; 510 ea_cache_entry *result = NULL; 511 511 512 512 if (file != NULL) { … … 548 548 const char *file; 549 549 int file_len; 550 mm_cache_entry *p;551 mm_fc_entry *fc;550 ea_cache_entry *p; 551 ea_fc_entry *fc; 552 552 zval *functions; 553 553 zval *classes; … … 575 575 array_init(functions); 576 576 while (fc != NULL) { 577 add_assoc_zval(functions, fc->htabkey, get_op_array((ea ccelerator_op_array *)fc->fc TSRMLS_CC));577 add_assoc_zval(functions, fc->htabkey, get_op_array((ea_op_array *)fc->fc TSRMLS_CC)); 578 578 fc = fc->next; 579 579 } … … 586 586 if (fc != NULL) { 587 587 while (fc != NULL) { 588 ea ccelerator_class_entry *c = (eaccelerator_class_entry *) fc->fc;588 ea_class_entry *c = (ea_class_entry *) fc->fc; 589 589 if (c->type == ZEND_USER_CLASS) { /* get methods */ 590 590 zval *methods; … … 595 595 q = c->function_table.pListHead; 596 596 while (q) { 597 ea ccelerator_op_array *func = (eaccelerator_op_array *) q->pData;597 ea_op_array *func = (ea_op_array *) q->pData; 598 598 if (func->type == ZEND_USER_FUNCTION) { 599 599 add_assoc_zval(methods, func->function_name, get_op_array(func TSRMLS_CC)); eaccelerator/trunk/ea_info.c
r237 r254 142 142 143 143 if ((f = open(file, O_RDONLY | O_BINARY)) > 0) { 144 mm_file_header hdr;144 ea_file_header hdr; 145 145 EACCELERATOR_FLOCK (f, LOCK_SH); 146 146 if (read(f, &hdr, sizeof(hdr)) != sizeof(hdr) … … 293 293 { 294 294 unsigned int i; 295 mm_cache_entry *p;295 ea_cache_entry *p; 296 296 297 297 if (!isAdminAllowed(TSRMLS_C)) { … … 305 305 p = eaccelerator_mm_instance->hash[i]; 306 306 while (p != NULL) { 307 mm_cache_entry *r = p;307 ea_cache_entry *r = p; 308 308 p = p->next; 309 309 eaccelerator_mm_instance->hash_cnt--; … … 320 320 } 321 321 for (i = 0; i < EA_USER_HASH_SIZE; i++) { 322 mm_user_cache_entry *p = eaccelerator_mm_instance->user_hash[i];322 ea_user_cache_entry *p = eaccelerator_mm_instance->user_hash[i]; 323 323 while (p != NULL) { 324 mm_user_cache_entry *r = p;324 ea_user_cache_entry *r = p; 325 325 p = p->next; 326 326 eaccelerator_mm_instance->user_hash_cnt--; … … 348 348 349 349 if (eaccelerator_mm_instance != NULL) { 350 mm_cache_entry *p, *q;350 ea_cache_entry *p, *q; 351 351 EACCELERATOR_UNPROTECT(); 352 352 EACCELERATOR_LOCK_RW(); … … 406 406 PHP_FUNCTION(eaccelerator_cached_scripts) 407 407 { 408 mm_cache_entry *p;408 ea_cache_entry *p; 409 409 int i; 410 410 … … 439 439 PHP_FUNCTION(eaccelerator_removed_scripts) 440 440 { 441 mm_cache_entry *p;441 ea_cache_entry *p; 442 442 zval *script; 443 443 eaccelerator/trunk/ea_restore.c
r251 r254 158 158 } 159 159 160 void fixup_op_array(ea ccelerator_op_array * from TSRMLS_DC)160 void fixup_op_array(ea_op_array * from TSRMLS_DC) 161 161 { 162 162 zend_op *opline; … … 242 242 } 243 243 244 void fixup_class_entry(ea ccelerator_class_entry * from TSRMLS_DC)244 void fixup_class_entry(ea_class_entry * from TSRMLS_DC) 245 245 { 246 246 FIXUP(from->name); … … 393 393 } 394 394 395 zend_op_array *restore_op_array(zend_op_array * to, 396 eaccelerator_op_array * from TSRMLS_DC) 395 zend_op_array *restore_op_array(zend_op_array * to, ea_op_array * from TSRMLS_DC) 397 396 { 398 397 union { … … 618 617 } 619 618 620 static zend_op_array *restore_op_array_ptr(eaccelerator_op_array * 621 from TSRMLS_DC) 619 static zend_op_array *restore_op_array_ptr(ea_op_array *from TSRMLS_DC) 622 620 { 623 621 return restore_op_array(NULL, from TSRMLS_CC); … … 735 733 #endif 736 734 737 zend_class_entry *restore_class_entry(zend_class_entry * to, 738 eaccelerator_class_entry * from TSRMLS_DC) 735 zend_class_entry *restore_class_entry(zend_class_entry * to, ea_class_entry * from TSRMLS_DC) 739 736 { 740 737 zend_class_entry *old; … … 844 841 } 845 842 846 restore_hash(&to->function_table, &from->function_table, 847 (restore_bucket_t) restore_op_array_ptr TSRMLS_CC); 843 restore_hash(&to->function_table, &from->function_table, (restore_bucket_t)restore_op_array_ptr TSRMLS_CC); 848 844 to->function_table.pDestructor = ZEND_FUNCTION_DTOR; 849 845 … … 861 857 } 862 858 863 void restore_function( mm_fc_entry * p TSRMLS_DC)859 void restore_function(ea_fc_entry * p TSRMLS_DC) 864 860 { 865 861 zend_op_array op_array; … … 868 864 return; 869 865 } 870 if (restore_op_array(&op_array, (ea ccelerator_op_array *) p->fc TSRMLS_CC) != NULL) {866 if (restore_op_array(&op_array, (ea_op_array *) p->fc TSRMLS_CC) != NULL) { 871 867 if (zend_hash_add(CG(function_table), p->htabkey, p->htablen, &op_array, sizeof(zend_op_array), NULL) == FAILURE) { 872 868 CG(in_compilation) = 1; … … 885 881 * Class handling. 886 882 */ 887 void restore_class( mm_fc_entry * p TSRMLS_DC)883 void restore_class(ea_fc_entry * p TSRMLS_DC) 888 884 { 889 885 #ifdef ZEND_ENGINE_2 … … 897 893 } 898 894 #ifdef ZEND_ENGINE_2 899 ce = restore_class_entry(NULL, (ea ccelerator_class_entry *) p->fc TSRMLS_CC);895 ce = restore_class_entry(NULL, (ea_class_entry *) p->fc TSRMLS_CC); 900 896 if (ce != NULL) 901 897 #else 902 if (restore_class_entry(&ce, (ea ccelerator_class_entry *) p->fc TSRMLS_CC) != NULL)898 if (restore_class_entry(&ce, (ea_class_entry *) p->fc TSRMLS_CC) != NULL) 903 899 #endif 904 900 { eaccelerator/trunk/ea_restore.h
r183 r254 30 30 31 31 #define FIXUP(x) if((x)!=NULL) {(x) = (void*)(((char*)(x)) + ((long)(EAG(mem))));} 32 void fixup_op_array(ea ccelerator_op_array *from TSRMLS_DC);33 void fixup_class_entry(ea ccelerator_class_entry *from TSRMLS_DC);32 void fixup_op_array(ea_op_array *from TSRMLS_DC); 33 void fixup_class_entry(ea_class_entry *from TSRMLS_DC); 34 34 void fixup_zval(zval *z TSRMLS_DC); 35 35 36 36 void restore_zval(zval *zv TSRMLS_DC); 37 void restore_class( mm_fc_entry *p TSRMLS_DC);38 void restore_function( mm_fc_entry *p TSRMLS_DC);39 zend_op_array* restore_op_array(zend_op_array *to, ea ccelerator_op_array *from TSRMLS_DC);40 zend_class_entry *restore_class_entry(zend_class_entry *to, ea ccelerator_class_entry *from TSRMLS_DC);37 void restore_class(ea_fc_entry *p TSRMLS_DC); 38 void restore_function(ea_fc_entry *p TSRMLS_DC); 39 zend_op_array* restore_op_array(zend_op_array *to, ea_op_array *from TSRMLS_DC); 40 zend_class_entry *restore_class_entry(zend_class_entry *to, ea_class_entry *from TSRMLS_DC); 41 41 void restore_class_parent(char *parent, int len, zend_class_entry *to TSRMLS_DC); 42 42 #ifdef ZEND_ENGINE_2 eaccelerator/trunk/ea_store.c
r248 r254 146 146 } else if (from->type == ZEND_USER_FUNCTION) { 147 147 EACCELERATOR_ALIGN(EAG(mem)); 148 EAG(mem) += sizeof(ea ccelerator_op_array);148 EAG(mem) += sizeof(ea_op_array); 149 149 } else { 150 150 DBG(ea_debug_error, ("[%d] EACCELERATOR can't cache function \"%s\"\n", getpid(), from->function_name)); … … 241 241 } 242 242 EACCELERATOR_ALIGN(EAG(mem)); 243 EAG(mem) += sizeof(ea ccelerator_class_entry);243 EAG(mem) += sizeof(ea_class_entry); 244 244 245 245 if (from->name != NULL) … … 284 284 285 285 zend_hash_init(&EAG(strings), 0, NULL, NULL, 0); 286 EAG(mem) += offsetof( mm_cache_entry, realfilename) + len + 1;286 EAG(mem) += offsetof(ea_cache_entry, realfilename) + len + 1; 287 287 zend_hash_add(&EAG(strings), key, len + 1, &key, sizeof(char *), NULL); 288 288 b = c; 289 289 while (b != NULL) { 290 290 EACCELERATOR_ALIGN(EAG(mem)); 291 EAG(mem) += offsetof( mm_fc_entry, htabkey) + b->nKeyLength;291 EAG(mem) += offsetof(ea_fc_entry, htabkey) + b->nKeyLength; 292 292 x = b->arKey; 293 293 zend_hash_add(&EAG(strings), b->arKey, b->nKeyLength, &x, sizeof(char *), NULL); … … 297 297 while (b != NULL) { 298 298 EACCELERATOR_ALIGN(EAG(mem)); 299 EAG(mem) += offsetof( mm_fc_entry, htabkey) + b->nKeyLength;299 EAG(mem) += offsetof(ea_fc_entry, htabkey) + b->nKeyLength; 300 300 x = b->arKey; 301 301 zend_hash_add(&EAG(strings), b->arKey, b->nKeyLength, &x, sizeof(char *), NULL); … … 473 473 } 474 474 475 ea ccelerator_op_array *store_op_array(zend_op_array * from TSRMLS_DC)476 { 477 ea ccelerator_op_array *to;475 ea_op_array *store_op_array(zend_op_array * from TSRMLS_DC) 476 { 477 ea_op_array *to; 478 478 zend_op *opline; 479 479 zend_op *end; … … 496 496 if (from->type == ZEND_INTERNAL_FUNCTION) { 497 497 EACCELERATOR_ALIGN(EAG(mem)); 498 to = (ea ccelerator_op_array *) EAG(mem);499 EAG(mem) += offsetof(ea ccelerator_op_array, opcodes);498 to = (ea_op_array *) EAG(mem); 499 EAG(mem) += offsetof(ea_op_array, opcodes); 500 500 } else if (from->type == ZEND_USER_FUNCTION) { 501 501 EACCELERATOR_ALIGN(EAG(mem)); 502 to = (ea ccelerator_op_array *) EAG(mem);503 EAG(mem) += sizeof(ea ccelerator_op_array);502 to = (ea_op_array *) EAG(mem); 503 EAG(mem) += sizeof(ea_op_array); 504 504 } else { 505 505 return NULL; … … 785 785 #endif 786 786 787 ea ccelerator_class_entry *store_class_entry(zend_class_entry * from TSRMLS_DC)788 { 789 ea ccelerator_class_entry *to;787 ea_class_entry *store_class_entry(zend_class_entry * from TSRMLS_DC) 788 { 789 ea_class_entry *to; 790 790 unsigned int i; 791 791 792 792 EACCELERATOR_ALIGN(EAG(mem)); 793 to = (ea ccelerator_class_entry *) EAG(mem);794 EAG(mem) += sizeof(ea ccelerator_class_entry);793 to = (ea_class_entry *) EAG(mem); 794 EAG(mem) += sizeof(ea_class_entry); 795 795 to->type = from->type; 796 796 to->name = NULL; eaccelerator/trunk/ea_store.h
r183 r254 35 35 36 36 void store_zval(zval *z TSRMLS_DC); 37 ea ccelerator_op_array *store_op_array(zend_op_array *from TSRMLS_DC);38 ea ccelerator_class_entry *store_class_entry_ptr(zend_class_entry **from TSRMLS_DC);39 ea ccelerator_class_entry *store_class_entry(zend_class_entry *from TSRMLS_DC);37 ea_op_array *store_op_array(zend_op_array *from TSRMLS_DC); 38 ea_class_entry *store_class_entry_ptr(zend_class_entry **from TSRMLS_DC); 39 ea_class_entry *store_class_entry(zend_class_entry *from TSRMLS_DC); 40 40 41 41 #endif /* EA_STORE_H */ eaccelerator/trunk/eaccelerator.c
r253 r254 80 80 81 81 /* Globals (common for each process/thread) */ 82 static long ea ccelerator_shm_size = 0;83 long ea ccelerator_shm_max = 0;84 static long ea ccelerator_shm_ttl = 0;85 static long ea ccelerator_shm_prune_period = 0;82 static long ea_shm_size = 0; 83 long ea_shm_max = 0; 84 static long ea_shm_ttl = 0; 85 static long ea_shm_prune_period = 0; 86 86 extern long eaccelerator_debug; 87 87 static zend_bool eaccelerator_check_mtime = 1; … … 122 122 123 123 /* Find a script entry with the given hash key */ 124 static mm_cache_entry* hash_find_mm(const char *key,124 static ea_cache_entry* hash_find_mm(const char *key, 125 125 struct stat *buf, 126 126 int *nreloads, 127 127 time_t ttl) { 128 128 unsigned int hv, slot; 129 mm_cache_entry *p, *q;129 ea_cache_entry *p, *q; 130 130 131 131 #ifdef EACCELERATOR_USE_INODE … … 193 193 194 194 /* Add a new entry to the hashtable */ 195 static void hash_add_mm( mm_cache_entry *x) {196 mm_cache_entry *p,*q;195 static void hash_add_mm(ea_cache_entry *x) { 196 ea_cache_entry *p,*q; 197 197 unsigned int slot; 198 198 #ifdef EACCELERATOR_USE_INODE … … 247 247 char mm_path[MAXPATHLEN]; 248 248 249 /* if (getppid() != 1) return SUCCESS; */ /*???*/250 249 #ifdef ZEND_WIN32 251 250 snprintf(mm_path, MAXPATHLEN, "%s.%s", EACCELERATOR_MM_FILE, sapi_module.name); 252 251 #else 253 snprintf(mm_path, MAXPATHLEN, "%s.%s%d", EACCELERATOR_MM_FILE, sapi_module.name, getpid());252 snprintf(mm_path, MAXPATHLEN, "%s.%s%d", EACCELERATOR_MM_FILE, sapi_module.name, owner); 254 253 #endif 255 254 /* snprintf(mm_path, MAXPATHLEN, "%s.%s%d", EACCELERATOR_MM_FILE, sapi_module.name, geteuid());*/ 256 if ((eaccelerator_mm_instance = (eaccelerator_mm*)mm_attach(ea ccelerator_shm_size*1024*1024, mm_path)) != NULL) {255 if ((eaccelerator_mm_instance = (eaccelerator_mm*)mm_attach(ea_shm_size*1024*1024, mm_path)) != NULL) { 257 256 #ifdef ZTS 258 257 ea_mutex = tsrm_mutex_alloc(); … … 260 259 return SUCCESS; 261 260 } 262 mm = mm_create(ea ccelerator_shm_size*1024*1024, mm_path);261 mm = mm_create(ea_shm_size*1024*1024, mm_path); 263 262 if (!mm) { 264 263 return FAILURE; 265 264 } 266 265 #ifdef ZEND_WIN32 267 DBG(ea_debug_printf, (EA_DEBUG, "init_mm [%d]\n", getpid()));268 #else 269 DBG(ea_debug_printf, (EA_DEBUG, "init_mm [%d,%d]\n", getpid(), getppid()));266 DBG(ea_debug_printf, (EA_DEBUG, "init_mm [%d]\n", owner)); 267 #else 268 DBG(ea_debug_printf, (EA_DEBUG, "init_mm [%d,%d]\n", owner, getppid())); 270 269 #endif 271 270 #ifdef ZTS … … 444 443 eaccelerator_mm_instance->last_prune = t; 445 444 for (i = 0; i < EA_HASH_SIZE; i++) { 446 mm_cache_entry **p = &eaccelerator_mm_instance->hash[i];445 ea_cache_entry **p = &eaccelerator_mm_instance->hash[i]; 447 446 while (*p != NULL) { 448 447 struct stat buf; … … 455 454 (*p)->mtime != buf.st_mtime || 456 455 (*p)->filesize != buf.st_size) { 457 mm_cache_entry *r = *p;456 ea_cache_entry *r = *p; 458 457 *p = (*p)->next; 459 458 eaccelerator_mm_instance->hash_cnt--; … … 478 477 } 479 478 } 480 if (ea ccelerator_shm_prune_period > 0) {479 if (ea_shm_prune_period > 0) { 481 480 t = time(0); 482 if (t - eaccelerator_mm_instance->last_prune > ea ccelerator_shm_prune_period) {481 if (t - eaccelerator_mm_instance->last_prune > ea_shm_prune_period) { 483 482 eaccelerator_prune(t); 484 483 p = eaccelerator_malloc(size); … … 565 564 } 566 565 567 void eaccelerator_fixup ( mm_cache_entry * p TSRMLS_DC)566 void eaccelerator_fixup (ea_cache_entry * p TSRMLS_DC) 568 567 { 569 mm_fc_entry *q;568 ea_fc_entry *q; 570 569 571 570 EAG (mem) = (char *) ((long) p - (long) p->next); … … 579 578 while (q != NULL) { 580 579 FIXUP (q->fc); 581 fixup_op_array ((ea ccelerator_op_array *) q->fc TSRMLS_CC);580 fixup_op_array ((ea_op_array *) q->fc TSRMLS_CC); 582 581 FIXUP (q->next); 583 582 q = q->next; … … 586 585 while (q != NULL) { 587 586 FIXUP (q->fc); 588 fixup_class_entry ((ea ccelerator_class_entry *) q->fc TSRMLS_CC);587 fixup_class_entry ((ea_class_entry *) q->fc TSRMLS_CC); 589 588 FIXUP (q->next); 590 589 q = q->next; … … 597 596 598 597 /* Retrieve a cache entry from the cache directory */ 599 static mm_cache_entry* hash_find_file(const char *key,598 static ea_cache_entry* hash_find_file(const char *key, 600 599 struct stat *buf TSRMLS_DC) { 601 600 int f; 602 601 char s[MAXPATHLEN]; 603 mm_file_header hdr;604 mm_cache_entry *p;602 ea_file_header hdr; 603 ea_cache_entry *p; 605 604 int use_shm = 1; 606 605 … … 686 685 p->use_cnt = 1; 687 686 p->removed = 0; 688 if (ea ccelerator_shm_ttl > 0) {689 p->ttl = time(0) + ea ccelerator_shm_ttl;687 if (ea_shm_ttl > 0) { 688 p->ttl = time(0) + ea_shm_ttl; 690 689 } else { 691 690 p->ttl = 0; … … 702 701 703 702 /* Add a cache entry to the cache directory */ 704 static int hash_add_file( mm_cache_entry *p TSRMLS_DC) {703 static int hash_add_file(ea_cache_entry *p TSRMLS_DC) { 705 704 int f; 706 705 int ret = 0; 707 706 char s[MAXPATHLEN]; 708 mm_file_header hdr;707 ea_file_header hdr; 709 708 710 709 #ifdef EACCELERATOR_USE_INODE … … 742 741 /* Create a cache entry from the given op_array, functions and classes of a 743 742 script */ 744 static mm_cache_entry *eaccelerator_store_int (char *key, int len,743 static ea_cache_entry *eaccelerator_store_int (char *key, int len, 745 744 zend_op_array * op_array, Bucket * f, Bucket * c TSRMLS_DC) 746 745 { 747 mm_cache_entry *p;748 mm_fc_entry *fc;749 mm_fc_entry *q;746 ea_cache_entry *p; 747 ea_fc_entry *fc; 748 ea_fc_entry *q; 750 749 char *x; 751 750 … … 756 755 EAG (compress) = 1; 757 756 zend_hash_init (&EAG (strings), 0, NULL, NULL, 0); 758 p = ( mm_cache_entry *) EAG (mem);759 EAG (mem) += offsetof ( mm_cache_entry, realfilename) + len + 1;757 p = (ea_cache_entry *) EAG (mem); 758 EAG (mem) += offsetof (ea_cache_entry, realfilename) + len + 1; 760 759 761 760 p->nhits = 0; … … 776 775 777 776 EACCELERATOR_ALIGN (EAG (mem)); 778 fc = ( mm_fc_entry *) EAG (mem);779 EAG (mem) += offsetof ( mm_fc_entry, htabkey) + c->nKeyLength;777 fc = (ea_fc_entry *) EAG (mem); 778 EAG (mem) += offsetof (ea_fc_entry, htabkey) + c->nKeyLength; 780 779 memcpy (fc->htabkey, c->arKey, c->nKeyLength); 781 780 fc->htablen = c->nKeyLength; … … 805 804 806 805 EACCELERATOR_ALIGN (EAG (mem)); 807 fc = ( mm_fc_entry *) EAG (mem);808 EAG (mem) += offsetof ( mm_fc_entry, htabkey) + f->nKeyLength;806 fc = (ea_fc_entry *) EAG (mem); 807 EAG (mem) += offsetof (ea_fc_entry, htabkey) + f->nKeyLength; 809 808 memcpy (fc->htabkey, f->arKey, f->nKeyLength); 810 809 fc->htablen = f->nKeyLength; … … 845 844 zend_op_array* op_array, 846 845 Bucket* f, Bucket *c TSRMLS_DC) { 847 mm_cache_entry *p;846 ea_cache_entry *p; 848 847 int len = strlen(key); 849 848 int use_shm = 1; … … 882 881 #endif 883 882 if (use_shm) { 884 if (ea ccelerator_shm_ttl > 0) {885 p->ttl = time(0) + ea ccelerator_shm_ttl;883 if (ea_shm_ttl > 0) { 884 p->ttl = time(0) +