@@ -141,6 +141,8 @@ static void preload_restart(void);
141
141
# define LOCKVAL (v ) (ZCSG(v))
142
142
#endif
143
143
144
+ #define ZCG_KEY_LEN (MAXPATHLEN * 8)
145
+
144
146
/**
145
147
* Clear AVX/SSE2-aligned memory.
146
148
*/
@@ -1190,7 +1192,7 @@ zend_string *accel_make_persistent_key(zend_string *str)
1190
1192
char * key ;
1191
1193
int key_length ;
1192
1194
1193
- ZSTR_LEN (& ZCG (key )) = 0 ;
1195
+ ZSTR_LEN (ZCG (key )) = 0 ;
1194
1196
1195
1197
/* CWD and include_path don't matter for absolute file names and streams */
1196
1198
if (IS_ABSOLUTE_PATH (path , path_length )) {
@@ -1300,7 +1302,7 @@ zend_string *accel_make_persistent_key(zend_string *str)
1300
1302
}
1301
1303
1302
1304
/* Calculate key length */
1303
- if (UNEXPECTED ((size_t )(cwd_len + path_length + include_path_len + 2 ) >= sizeof ( ZCG ( _key )) )) {
1305
+ if (UNEXPECTED ((size_t )(cwd_len + path_length + include_path_len + 2 ) >= ZCG_KEY_LEN )) {
1304
1306
return NULL ;
1305
1307
}
1306
1308
@@ -1309,7 +1311,7 @@ zend_string *accel_make_persistent_key(zend_string *str)
1309
1311
* since in itself, it may include colons (which we use to separate
1310
1312
* different components of the key)
1311
1313
*/
1312
- key = ZSTR_VAL (& ZCG (key ));
1314
+ key = ZSTR_VAL (ZCG (key ));
1313
1315
memcpy (key , path , path_length );
1314
1316
key [path_length ] = ':' ;
1315
1317
key_length = path_length + 1 ;
@@ -1333,7 +1335,7 @@ zend_string *accel_make_persistent_key(zend_string *str)
1333
1335
parent_script_len = ZSTR_LEN (parent_script );
1334
1336
while ((-- parent_script_len > 0 ) && !IS_SLASH (ZSTR_VAL (parent_script )[parent_script_len ]));
1335
1337
1336
- if (UNEXPECTED ((size_t )(key_length + parent_script_len + 1 ) >= sizeof ( ZCG ( _key )) )) {
1338
+ if (UNEXPECTED ((size_t )(key_length + parent_script_len + 1 ) >= ZCG_KEY_LEN )) {
1337
1339
return NULL ;
1338
1340
}
1339
1341
key [key_length ] = ':' ;
@@ -1342,11 +1344,11 @@ zend_string *accel_make_persistent_key(zend_string *str)
1342
1344
key_length += parent_script_len ;
1343
1345
}
1344
1346
key [key_length ] = '\0' ;
1345
- GC_SET_REFCOUNT (& ZCG (key ), 1 );
1346
- GC_TYPE_INFO (& ZCG (key )) = GC_STRING ;
1347
- ZSTR_H (& ZCG (key )) = 0 ;
1348
- ZSTR_LEN (& ZCG (key )) = key_length ;
1349
- return & ZCG (key );
1347
+ GC_SET_REFCOUNT (ZCG (key ), 1 );
1348
+ GC_TYPE_INFO (ZCG (key )) = ( GC_STRING | IS_STR_PERSISTENT ) ;
1349
+ ZSTR_H (ZCG (key )) = 0 ;
1350
+ ZSTR_LEN (ZCG (key )) = key_length ;
1351
+ return ZCG (key );
1350
1352
}
1351
1353
1352
1354
/* not use_cwd */
@@ -2014,8 +2016,8 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
2014
2016
ZCG (cache_opline ) == EG (current_execute_data )-> opline ))) {
2015
2017
2016
2018
persistent_script = ZCG (cache_persistent_script );
2017
- if (ZSTR_LEN (& ZCG (key ))) {
2018
- key = & ZCG (key );
2019
+ if (ZSTR_LEN (ZCG (key ))) {
2020
+ key = ZCG (key );
2019
2021
}
2020
2022
2021
2023
} else {
@@ -2555,7 +2557,7 @@ static zend_string* persistent_zend_resolve_path(zend_string *filename)
2555
2557
SHM_PROTECT ();
2556
2558
HANDLE_UNBLOCK_INTERRUPTIONS ();
2557
2559
} else {
2558
- ZSTR_LEN (& ZCG (key )) = 0 ;
2560
+ ZSTR_LEN (ZCG (key )) = 0 ;
2559
2561
}
2560
2562
ZCG (cache_opline ) = EG (current_execute_data ) ? EG (current_execute_data )-> opline : NULL ;
2561
2563
ZCG (cache_persistent_script ) = persistent_script ;
@@ -2927,7 +2929,15 @@ static void accel_globals_ctor(zend_accel_globals *accel_globals)
2927
2929
ZEND_TSRMLS_CACHE_UPDATE ();
2928
2930
#endif
2929
2931
memset (accel_globals , 0 , sizeof (zend_accel_globals ));
2932
+ accel_globals -> key = zend_string_alloc (ZCG_KEY_LEN , true);
2933
+ }
2934
+
2935
+ #ifdef ZTS
2936
+ static void accel_globals_dtor (zend_accel_globals * accel_globals )
2937
+ {
2938
+ zend_string_free (accel_globals -> key );
2930
2939
}
2940
+ #endif
2931
2941
2932
2942
#ifdef HAVE_HUGE_CODE_PAGES
2933
2943
# ifndef _WIN32
@@ -3100,7 +3110,7 @@ static void accel_move_code_to_huge_pages(void)
3100
3110
static int accel_startup (zend_extension * extension )
3101
3111
{
3102
3112
#ifdef ZTS
3103
- accel_globals_id = ts_allocate_id (& accel_globals_id , sizeof (zend_accel_globals ), (ts_allocate_ctor ) accel_globals_ctor , NULL );
3113
+ accel_globals_id = ts_allocate_id (& accel_globals_id , sizeof (zend_accel_globals ), (ts_allocate_ctor ) accel_globals_ctor , ( ts_allocate_dtor ) accel_globals_dtor );
3104
3114
#else
3105
3115
accel_globals_ctor (& accel_globals );
3106
3116
#endif
0 commit comments