Changeset 333
- Timestamp:
- 08/20/07 18:40:16 (9 months ago)
- Files:
-
- eaccelerator/trunk/ChangeLog (modified) (1 diff)
- eaccelerator/trunk/eaccelerator.c (modified) (5 diffs)
- eaccelerator/trunk/mm.c (modified) (5 diffs)
- eaccelerator/trunk/mm.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
eaccelerator/trunk/ChangeLog
r332 r333 20 20 * Rewrite the fixup_* functions so they no longer use the EAG(mem) global. 21 21 * Rewrite store_* functions so they no longer use the EAG(mem) global. 22 * Add code that checks the shared memory chunks if needed to make sure 23 no data was written past the boundary. Change #undef MM_CHECK in mm.c 24 to #define MM_CHECK 22 25 23 26 2007-08-19 Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> eaccelerator/trunk/eaccelerator.c
r330 r333 749 749 p->removed = 1; 750 750 } 751 mm_check_mem(p); 751 752 return p; 752 753 } … … 800 801 int ret = 0; 801 802 int size = 0; 803 void *data = NULL; 802 804 803 805 zend_try { … … 815 817 EACCELERATOR_UNPROTECT(); 816 818 EAG(mem) = eaccelerator_malloc(size); 819 data = EAG(mem); 817 820 if (EAG(mem) == NULL) { 818 821 EAG(mem) = eaccelerator_malloc2(size TSRMLS_CC); … … 825 828 if (EAG(mem)) { 826 829 memset(EAG(mem), 0, size); 827 p = eaccelerator_store_int(key, len, op_array, f, c TSRMLS_CC); 830 p = (ea_cache_entry *)EAG(mem); 831 eaccelerator_store_int(p, key, len, op_array, f, c TSRMLS_CC); 828 832 p->mtime = buf->st_mtime; 829 833 p->filesize = buf->st_size; … … 846 850 EACCELERATOR_PROTECT(); 847 851 ret = 1; 852 mm_check_mem(data); 848 853 } else { 849 854 ret = hash_add_file(p TSRMLS_CC); eaccelerator/trunk/mm.c
r301 r333 67 67 #endif 68 68 69 #undef MM_CHECK 70 #define MM_PATTERN 0xdeadbeef 71 69 72 #if defined(MM_SHM_MMAP_FILE) || defined(MM_SHM_MMAP_ZERO) || defined(MM_SHM_MMAP_ANON) || defined(MM_SHM_MMAP_POSIX) || defined(HAVE_MPROTECT) 70 73 # include <sys/mman.h> … … 1066 1069 mm_mem_head* x = NULL; 1067 1070 size_t realsize = (size_t)MM_ALIGN(MM_SIZE(size)); 1071 #if MM_CHECK 1072 realsize += (size_t)MM_ALIGN(sizeof(int)); 1073 #endif 1068 1074 if (realsize <= mm->available) { 1069 1075 /* Search for free bucket */ … … 1084 1090 break; 1085 1091 } else if (p->size > realsize && (best == NULL || best->size > p->size)) { 1086 /* Found best bucket (smallest bucket with the grater size) */1092 /* Found best bucket (smallest bucket with the bigger size) */ 1087 1093 best = p; 1088 1094 best_prev = q; … … 1119 1125 } 1120 1126 if (x != NULL) { 1127 #ifdef MM_CHECK 1128 *(int *)((char *)x + realsize - (size_t)MM_ALIGN(sizeof(int))) = MM_PATTERN; 1129 #endif 1121 1130 return HEAD_TO_PTR(x); 1122 1131 } … … 1319 1328 } 1320 1329 1330 #if defined(MM_CHECK) && !(defined(MM_TEST_SHM) || defined(MM_TEST_SEM)) 1331 void mm_check_mem(void *x) { 1332 mm_mem_head *p = PTR_TO_HEAD(x); 1333 if (*((unsigned int *)((char *)p + p->size - (size_t)MM_ALIGN(sizeof(int)))) != MM_PATTERN) { 1334 ea_debug_error("[EACCELERATOR] Corrupted memory detected\n"); 1335 } 1336 } 1337 #else 1338 void mm_check_mem(void *x) {} 1339 #endif 1340 1321 1341 #ifdef MM_TEST_SHM 1322 1342 int main() { eaccelerator/trunk/mm.h
r286 r333 67 67 const char* mm_shm_type(); 68 68 const char* mm_sem_type(); 69 void mm_check_mem(void *x); 69 70 70 71 #define MM_PROT_NONE 1