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