Changeset 256
- Timestamp:
- 07/29/06 14:28:19 (4 years ago)
- Location:
- eaccelerator/trunk
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
eaccelerator.c (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
eaccelerator/trunk/ChangeLog
r255 r256 7 7 * Move some functions around to make more of them static, this reduces 8 8 the binary size and load times. 9 9 * Remove some leftovers from restoring encoded scripts which only create 10 overhead without the loader. 11 10 12 2006-07-29 Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 11 13 -
eaccelerator/trunk/eaccelerator.c
r255 r256 4 4 +----------------------------------------------------------------------+ 5 5 | Copyright (c) 2004 - 2006 eAccelerator | 6 | http://eaccelerator.net |6 | http://eaccelerator.net | 7 7 +----------------------------------------------------------------------+ 8 8 | This program is free software; you can redistribute it and/or | … … 920 920 #ifndef ZEND_WIN32 921 921 if (file_handle->type == ZEND_HANDLE_FP && file_handle->handle.fp != NULL) { 922 if (fstat(fileno(file_handle->handle.fp), buf) == 0 && 923 S_ISREG(buf->st_mode)) { 922 if (fstat(fileno(file_handle->handle.fp), buf) == 0 && S_ISREG(buf->st_mode)) { 924 923 if (file_handle->opened_path != NULL) { 925 strcpy(realname, file_handle->opened_path);924 strcpy(realname, file_handle->opened_path); 926 925 } 927 926 return 0; … … 930 929 #endif 931 930 if (file_handle->opened_path != NULL) { 932 if (stat(file_handle->opened_path, buf) == 0 && 933 S_ISREG(buf->st_mode)) { 931 if (stat(file_handle->opened_path, buf) == 0 && S_ISREG(buf->st_mode)) { 934 932 strcpy(realname,file_handle->opened_path); 935 933 return 0; 936 934 } 937 } else if (PG(include_path) == NULL || 938 file_handle->filename[0] == '.' ||935 } else if (PG(include_path) == NULL || 936 file_handle->filename[0] == '.' || 939 937 IS_SLASH(file_handle->filename[0]) || 940 938 IS_ABSOLUTE_PATH(file_handle->filename,strlen(file_handle->filename))) { 941 if (stat(file_handle->filename, buf) == 0 && 942 S_ISREG(buf->st_mode)) { 939 if (stat(file_handle->filename, buf) == 0 && S_ISREG(buf->st_mode)) { 943 940 return 0; 944 941 } … … 953 950 end = strchr(ptr, DEFAULT_DIR_SEPARATOR); 954 951 if (end != NULL) { 955 len = end -ptr;952 len = end - ptr; 956 953 end++; 957 954 } else { 958 955 len = strlen(ptr); 959 end = ptr +len;960 } 961 if (len +filename_len+2 < MAXPATHLEN) {956 end = ptr + len; 957 } 958 if (len + filename_len + 2 < MAXPATHLEN) { 962 959 memcpy(tryname, ptr, len); 963 960 tryname[len] = '/'; 964 memcpy(tryname+len+1, file_handle->filename, filename_len); 965 tryname[len+filename_len+1] = '\0'; 966 if (stat(tryname, buf) == 0 && 967 S_ISREG(buf->st_mode)) { 961 memcpy(tryname + len + 1, file_handle->filename, filename_len); 962 tryname[len + filename_len + 1] = '\0'; 963 if (stat(tryname, buf) == 0 && S_ISREG(buf->st_mode)) { 968 964 return 0; 969 965 } … … 978 974 tryname_length = strlen(tryname); 979 975 980 while (tryname_length >= 0 && !IS_SLASH(tryname[tryname_length])) 976 while (tryname_length >= 0 && !IS_SLASH(tryname[tryname_length])) { 981 977 tryname_length--; 978 } 982 979 if (tryname_length > 0 && tryname[0] != '[' // [no active file] 983 980 && tryname_length + filename_len + 1 < MAXPATHLEN) 984 981 { 985 982 strncpy(tryname + tryname_length + 1, file_handle->filename, filename_len + 1); 986 if (stat(tryname, buf) == 0 && S_ISREG(buf->st_mode)) 983 if (stat(tryname, buf) == 0 && S_ISREG(buf->st_mode)) { 987 984 return 0; 985 } 988 986 } 989 987 } … … 997 995 if (!eaccelerator_check_mtime) { 998 996 return 0; 999 } else if (fstat(fileno(file_handle->handle.fp), buf) == 0 && 1000 S_ISREG(buf->st_mode)) { 997 } else if (fstat(fileno(file_handle->handle.fp), buf) == 0 && S_ISREG(buf->st_mode)) { 1001 998 return 0; 1002 999 } else { … … 1006 1003 if (!eaccelerator_check_mtime) { 1007 1004 return 0; 1008 } else if (stat(realname, buf) == 0 && 1009 S_ISREG(buf->st_mode)) { 1005 } else if (stat(realname, buf) == 0 && S_ISREG(buf->st_mode)) { 1010 1006 return 0; 1011 1007 } else { … … 1016 1012 if (!eaccelerator_check_mtime) { 1017 1013 return 0; 1018 } else if (stat(realname, buf) == 0 && 1019 S_ISREG(buf->st_mode)) { 1014 } else if (stat(realname, buf) == 0 && S_ISREG(buf->st_mode)) { 1020 1015 return 0; 1021 1016 } else { … … 1025 1020 } else if (file_handle->filename == NULL) { 1026 1021 return -1; 1027 } else if (PG(include_path) == NULL || 1022 } else if (PG(include_path) == NULL || 1028 1023 file_handle->filename[0] == '.' || 1029 1024 IS_SLASH(file_handle->filename[0]) || … … 1032 1027 if (!eaccelerator_check_mtime) { 1033 1028 return 0; 1034 } else if (stat(realname, buf) == 0 && 1035 S_ISREG(buf->st_mode)) { 1029 } else if (stat(realname, buf) == 0 && S_ISREG(buf->st_mode)) { 1036 1030 return 0; 1037 1031 } else { … … 1049 1043 end = strchr(ptr, DEFAULT_DIR_SEPARATOR); 1050 1044 if (end != NULL) { 1051 len = end -ptr;1045 len = end - ptr; 1052 1046 end++; 1053 1047 } else { 1054 1048 len = strlen(ptr); 1055 end = ptr +len;1049 end = ptr + len; 1056 1050 } 1057 1051 if (len+filename_len+2 < MAXPATHLEN) { 1058 1052 memcpy(tryname, ptr, len); 1059 1053 tryname[len] = '/'; 1060 memcpy(tryname +len+1, file_handle->filename, filename_len);1061 tryname[len +filename_len+1] = '\0';1054 memcpy(tryname + len + 1, file_handle->filename, filename_len); 1055 tryname[len + filename_len + 1] = '\0'; 1062 1056 if (VCWD_REALPATH(tryname, realname)) { 1063 1057 #ifdef ZEND_WIN32 1064 if (stat(realname, buf) == 0 && 1065 S_ISREG(buf->st_mode)) { 1058 if (stat(realname, buf) == 0 && S_ISREG(buf->st_mode)) { 1066 1059 return 0; 1067 1060 } … … 1069 1062 if (!eaccelerator_check_mtime) { 1070 1063 return 0; 1071 } else if (stat(realname, buf) == 0 && 1072 S_ISREG(buf->st_mode)) { 1064 } else if (stat(realname, buf) == 0 && S_ISREG(buf->st_mode)) { 1073 1065 return 0; 1074 1066 } else { … … 1107 1099 realname[0] = '\000'; 1108 1100 #endif 1101 1109 1102 DBG(ea_debug_start_time, (&tv_start)); 1110 1103 DBG(ea_debug_printf, (EA_DEBUG, "[%d] Enter COMPILE\n",getpid())); … … 1195 1188 int ea_bailout; 1196 1189 1197 DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] compile_file: marking\n", getpid())); 1190 #ifdef DEBUG 1191 ea_debug_printf(EA_DEBUG, "\t[%d] compile_file: marking\n", getpid()); 1198 1192 if (CG(class_table) != EG(class_table)) { 1199 DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] oops, CG(class_table)[%08x] != EG(class_table)[%08x]\n", 1200 getpid(), CG(class_table), EG(class_table))); 1201 DBG(ea_debug_log_hashkeys, ("CG(class_table)\n", CG(class_table))); 1202 DBG(ea_debug_log_hashkeys, ("EG(class_table)\n", EG(class_table))); 1193 ea_debug_printf(EA_DEBUG, "\t[%d] oops, CG(class_table)[%08x] != EG(class_table)[%08x]\n", getpid(), CG(class_table), EG(class_table)); 1194 ea_debug_log_hashkeys("CG(class_table)\n", CG(class_table)); 1195 ea_debug_log_hashkeys("EG(class_table)\n", EG(class_table)); 1203 1196 } else { 1204 DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] OKAY. That what I thought, CG(class_table)[%08x] == EG(class_table)[%08x]\n", 1205 getpid(), CG(class_table), EG(class_table))); 1206 DBG(ea_debug_log_hashkeys, ("CG(class_table)\n", CG(class_table))); 1207 } 1208 1209 zend_hash_init_ex(&tmp_function_table, 100, NULL, ZEND_FUNCTION_DTOR, 1, 0); 1210 zend_hash_copy(&tmp_function_table, &eaccelerator_global_function_table, NULL, &tmp_func, sizeof(zend_function)); 1211 orig_function_table = CG(function_table); 1212 CG(function_table) = &tmp_function_table; 1213 1214 zend_hash_init_ex(&tmp_class_table, 10, NULL, ZEND_CLASS_DTOR, 1, 0); 1215 zend_hash_copy(&tmp_class_table, &eaccelerator_global_class_table, NULL, &tmp_class, sizeof(zend_class_entry)); 1216 1217 orig_class_table = CG(class_table);; 1218 CG(class_table) = &tmp_class_table; 1219 #ifdef ZEND_ENGINE_2 1220 orig_eg_class_table = EG(class_table);; 1221 EG(class_table) = &tmp_class_table; 1197 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)); 1198 ea_debug_log_hashkeys("CG(class_table)\n", CG(class_table)); 1199 } 1222 1200 #endif 1223 1201 … … 1226 1204 class_table_tail = CG(class_table)->pListTail; 1227 1205 1228 DBG(ea_debug_printf, (EA_TEST_PERFORMANCE, "\t[%d] compile_file: compiling (%ld)\n",getpid(),ea_debug_elapsed_time(&tv_start))); 1229 DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] compile_file: compiling tmp_class_table=%d class_table=%d\n", 1230 getpid(), tmp_class_table.nNumOfElements, orig_class_table->nNumOfElements)); 1206 DBG(ea_debug_printf, (EA_TEST_PERFORMANCE, "\t[%d] compile_file: compiling (%ld)\n", getpid(), ea_debug_elapsed_time(&tv_start))); 1207 1231 1208 if (EAG(optimizer_enabled) && eaccelerator_mm_instance->optimizer_enabled) { 1232 1209 EAG(compiler) = 1; 1233 1210 } 1234 1211 1212 /* try to compile the script */ 1235 1213 ea_bailout = 0; 1236 1214 zend_try { 1237 1215 t = mm_saved_zend_compile_file(file_handle, type TSRMLS_CC); 1238 1216 } zend_catch { 1239 CG(function_table) = orig_function_table;1240 CG(class_table) = orig_class_table;1241 #ifdef ZEND_ENGINE_21242 EG(class_table) = orig_eg_class_table;1243 #endif1244 1217 ea_bailout = 1; 1245 1218 } zend_end_try(); … … 1249 1222 DBG(ea_debug_log_hashkeys, ("class_table\n", CG(class_table))); 1250 1223 1251 /*???1252 if (file_handle->opened_path == NULL && t != NULL) {1253 file_handle->opened_path = t->filename;1254 }1255 */1256 1224 EAG(compiler) = 0; 1257 1225 if (t != NULL && file_handle->opened_path != NULL && (eaccelerator_check_mtime || … … 1259 1227 DBG(ea_debug_printf, (EA_TEST_PERFORMANCE, "\t[%d] compile_file: storing in cache (%ld)\n", getpid(), ea_debug_elapsed_time(&tv_start))); 1260 1228 DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] compile_file: storing in cache\n", getpid())); 1261 function_table_tail = function_table_tail ?function_table_tail->pListNext:CG(function_table)->pListHead;1262 class_table_tail = class_table_tail ?class_table_tail->pListNext:CG(class_table)->pListHead;1229 function_table_tail = function_table_tail ? function_table_tail->pListNext : CG(function_table)->pListHead; 1230 class_table_tail = class_table_tail ? class_table_tail->pListNext : CG(class_table)->pListHead; 1263 1231 if (eaccelerator_store(file_handle->opened_path, &buf, nreloads, t, function_table_tail, class_table_tail TSRMLS_CC)) { 1264 1232 #ifdef DEBUG … … 1275 1243 } 1276 1244 } else { 1277 function_table_tail = function_table_tail?function_table_tail->pListNext:CG(function_table)->pListHead; 1278 class_table_tail = class_table_tail?class_table_tail->pListNext:CG(class_table)->pListHead; 1279 } 1280 CG(function_table) = orig_function_table; 1281 CG(class_table) = orig_class_table; 1282 #ifdef ZEND_ENGINE_2 1283 EG(class_table) = orig_eg_class_table; 1284 DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] restoring CG(class_table)[%08x] != EG(class_table)[%08x]\n", 1285 getpid(), CG(class_table), EG(class_table))); 1286 #endif 1287 while (function_table_tail != NULL) { 1288 zend_op_array *op_array = (zend_op_array*)function_table_tail->pData; 1289 if (op_array->type == ZEND_USER_FUNCTION) { 1290 if (zend_hash_add(CG(function_table), function_table_tail->arKey, function_table_tail->nKeyLength, op_array, 1291 sizeof(zend_op_array), NULL) == FAILURE && function_table_tail->arKey[0] != '\000') { 1292 CG(in_compilation) = 1; 1293 CG(compiled_filename) = file_handle->opened_path; 1294 #ifdef ZEND_ENGINE_2 1295 CG(zend_lineno) = op_array->line_start; 1296 #else 1297 CG(zend_lineno) = op_array->opcodes[0].lineno; 1298 #endif 1299 zend_error(E_ERROR, "Cannot redeclare %s()", function_table_tail->arKey); 1300 } 1301 } 1302 function_table_tail = function_table_tail->pListNext; 1303 } 1304 while (class_table_tail != NULL) { 1305 #ifdef ZEND_ENGINE_2 1306 zend_class_entry **ce = (zend_class_entry**)class_table_tail->pData; 1307 if ((*ce)->type == ZEND_USER_CLASS) { 1308 if (zend_hash_add(CG(class_table), class_table_tail->arKey, class_table_tail->nKeyLength, 1309 ce, sizeof(zend_class_entry*), NULL) == FAILURE && class_table_tail->arKey[0] != '\000') { 1310 CG(in_compilation) = 1; 1311 CG(compiled_filename) = file_handle->opened_path; 1312 CG(zend_lineno) = (*ce)->line_start; 1313 #else 1314 zend_class_entry *ce = (zend_class_entry*)class_table_tail->pData; 1315 if (ce->type == ZEND_USER_CLASS) { 1316 if (ce->parent != NULL) { 1317 if (zend_hash_find(CG(class_table), (void*)ce->parent->name, ce->parent->name_length+1, (void **)&ce->parent) != SUCCESS) { 1318 ce->parent = NULL; 1319 } 1320 } 1321 if (zend_hash_add(CG(class_table), class_table_tail->arKey, class_table_tail->nKeyLength, ce, 1322 sizeof(zend_class_entry), NULL) == FAILURE && class_table_tail->arKey[0] != '\000') { 1323 CG(in_compilation) = 1; 1324 CG(compiled_filename) = file_handle->opened_path; 1325 CG(zend_lineno) = 0; 1326 #endif 1327 zend_error(E_ERROR, "Cannot redeclare class %s", class_table_tail->arKey); 1328 } 1329 } 1330 class_table_tail = class_table_tail->pListNext; 1331 } 1332 tmp_function_table.pDestructor = NULL; 1333 tmp_class_table.pDestructor = NULL; 1334 zend_hash_destroy(&tmp_function_table); 1335 zend_hash_destroy(&tmp_class_table); 1245 function_table_tail = function_table_tail ? function_table_tail->pListNext : CG(function_table)->pListHead; 1246 class_table_tail = class_table_tail ? class_table_tail->pListNext : CG(class_table)->pListHead; 1247 } 1336 1248 } 1337 1249 DBG(ea_debug_printf, (EA_TEST_PERFORMANCE, "\t[%d] compile_file: end (%ld)\n", getpid(), ea_debug_elapsed_time(&tv_start)));
Note: See TracChangeset
for help on using the changeset viewer.