@@ -1047,6 +1047,55 @@ static inline char *accel_make_persistent_key(zend_file_handle *file_handle, int
10471047 return accel_make_persistent_key_ex (file_handle , strlen (file_handle -> filename ), key_len TSRMLS_CC );
10481048}
10491049
1050+ int zend_accel_invalidate (const char * filename , int filename_len , zend_bool force TSRMLS_DC )
1051+ {
1052+ char * realpath ;
1053+ zend_persistent_script * persistent_script ;
1054+
1055+ if (!ZCG (enabled ) || !accel_startup_ok || !ZCSG (accelerator_enabled ) || accelerator_shm_read_lock (TSRMLS_C ) != SUCCESS ) {
1056+ return FAILURE ;
1057+ }
1058+
1059+ #if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO
1060+ realpath = accel_php_resolve_path (filename , filename_len , ZCG (include_path ) TSRMLS_CC );
1061+ #else
1062+ realpath = accelerator_orig_zend_resolve_path (filename , filename_len TSRMLS_CC );
1063+ #endif
1064+
1065+ persistent_script = zend_accel_hash_find (& ZCSG (hash ), realpath , strlen (realpath ) + 1 );
1066+ if (persistent_script && !persistent_script -> corrupted ) {
1067+ zend_file_handle file_handle ;
1068+
1069+ file_handle .type = ZEND_HANDLE_FILENAME ;
1070+ file_handle .filename = realpath ;
1071+ file_handle .opened_path = realpath ;
1072+
1073+ if (force ||
1074+ !ZCG (accel_directives ).validate_timestamps ||
1075+ do_validate_timestamps (persistent_script , & file_handle TSRMLS_CC ) == FAILURE ) {
1076+ SHM_UNPROTECT ();
1077+ zend_shared_alloc_lock (TSRMLS_C );
1078+ if (!persistent_script -> corrupted ) {
1079+ persistent_script -> corrupted = 1 ;
1080+ persistent_script -> timestamp = 0 ;
1081+ ZSMMG (wasted_shared_memory ) += persistent_script -> dynamic_members .memory_consumption ;
1082+ if (ZSMMG (memory_exhausted )) {
1083+ zend_accel_restart_reason reason =
1084+ zend_accel_hash_is_full (& ZCSG (hash )) ? ACCEL_RESTART_HASH : ACCEL_RESTART_OOM ;
1085+ zend_accel_schedule_restart_if_necessary (reason TSRMLS_CC );
1086+ }
1087+ }
1088+ zend_shared_alloc_unlock (TSRMLS_C );
1089+ SHM_PROTECT ();
1090+ }
1091+ }
1092+
1093+ accelerator_shm_read_unlock (TSRMLS_C );
1094+ efree (realpath );
1095+
1096+ return SUCCESS ;
1097+ }
1098+
10501099/* Adds another key for existing cached script */
10511100static void zend_accel_add_key (char * key , unsigned int key_length , zend_accel_hash_entry * bucket TSRMLS_DC )
10521101{
0 commit comments