@@ -146,6 +146,8 @@ static void preload_restart(void);
146
146
# define LOCKVAL (v ) (ZCSG(v))
147
147
#endif
148
148
149
+ #define ZCG_KEY_LEN (MAXPATHLEN * 8)
150
+
149
151
/**
150
152
* Clear AVX/SSE2-aligned memory.
151
153
*/
@@ -1195,7 +1197,8 @@ zend_string *accel_make_persistent_key(zend_string *str)
1195
1197
char * key ;
1196
1198
int key_length ;
1197
1199
1198
- ZSTR_LEN (& ZCG (key )) = 0 ;
1200
+ ZEND_ASSERT (GC_REFCOUNT (ZCG (key )) == 1 );
1201
+ ZSTR_LEN (ZCG (key )) = 0 ;
1199
1202
1200
1203
/* CWD and include_path don't matter for absolute file names and streams */
1201
1204
if (IS_ABSOLUTE_PATH (path , path_length )) {
@@ -1305,7 +1308,7 @@ zend_string *accel_make_persistent_key(zend_string *str)
1305
1308
}
1306
1309
1307
1310
/* Calculate key length */
1308
- if (UNEXPECTED ((size_t )(cwd_len + path_length + include_path_len + 2 ) >= sizeof ( ZCG ( _key )) )) {
1311
+ if (UNEXPECTED ((size_t )(cwd_len + path_length + include_path_len + 2 ) >= ZCG_KEY_LEN )) {
1309
1312
return NULL ;
1310
1313
}
1311
1314
@@ -1314,7 +1317,7 @@ zend_string *accel_make_persistent_key(zend_string *str)
1314
1317
* since in itself, it may include colons (which we use to separate
1315
1318
* different components of the key)
1316
1319
*/
1317
- key = ZSTR_VAL (& ZCG (key ));
1320
+ key = ZSTR_VAL (ZCG (key ));
1318
1321
memcpy (key , path , path_length );
1319
1322
key [path_length ] = ':' ;
1320
1323
key_length = path_length + 1 ;
@@ -1338,7 +1341,7 @@ zend_string *accel_make_persistent_key(zend_string *str)
1338
1341
parent_script_len = ZSTR_LEN (parent_script );
1339
1342
while ((-- parent_script_len > 0 ) && !IS_SLASH (ZSTR_VAL (parent_script )[parent_script_len ]));
1340
1343
1341
- if (UNEXPECTED ((size_t )(key_length + parent_script_len + 1 ) >= sizeof ( ZCG ( _key )) )) {
1344
+ if (UNEXPECTED ((size_t )(key_length + parent_script_len + 1 ) >= ZCG_KEY_LEN )) {
1342
1345
return NULL ;
1343
1346
}
1344
1347
key [key_length ] = ':' ;
@@ -1347,11 +1350,9 @@ zend_string *accel_make_persistent_key(zend_string *str)
1347
1350
key_length += parent_script_len ;
1348
1351
}
1349
1352
key [key_length ] = '\0' ;
1350
- GC_SET_REFCOUNT (& ZCG (key ), 1 );
1351
- GC_TYPE_INFO (& ZCG (key )) = GC_STRING ;
1352
- ZSTR_H (& ZCG (key )) = 0 ;
1353
- ZSTR_LEN (& ZCG (key )) = key_length ;
1354
- return & ZCG (key );
1353
+ ZSTR_H (ZCG (key )) = 0 ;
1354
+ ZSTR_LEN (ZCG (key )) = key_length ;
1355
+ return ZCG (key );
1355
1356
}
1356
1357
1357
1358
/* not use_cwd */
@@ -2026,8 +2027,8 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
2026
2027
ZCG (cache_opline ) == EG (current_execute_data )-> opline ))) {
2027
2028
2028
2029
persistent_script = ZCG (cache_persistent_script );
2029
- if (ZSTR_LEN (& ZCG (key ))) {
2030
- key = & ZCG (key );
2030
+ if (ZSTR_LEN (ZCG (key ))) {
2031
+ key = ZCG (key );
2031
2032
}
2032
2033
2033
2034
} else {
@@ -2580,7 +2581,7 @@ static zend_string* persistent_zend_resolve_path(zend_string *filename)
2580
2581
SHM_PROTECT ();
2581
2582
HANDLE_UNBLOCK_INTERRUPTIONS ();
2582
2583
} else {
2583
- ZSTR_LEN (& ZCG (key )) = 0 ;
2584
+ ZSTR_LEN (ZCG (key )) = 0 ;
2584
2585
}
2585
2586
ZCG (cache_opline ) = EG (current_execute_data ) ? EG (current_execute_data )-> opline : NULL ;
2586
2587
ZCG (cache_persistent_script ) = persistent_script ;
@@ -2952,7 +2953,15 @@ static void accel_globals_ctor(zend_accel_globals *accel_globals)
2952
2953
ZEND_TSRMLS_CACHE_UPDATE ();
2953
2954
#endif
2954
2955
memset (accel_globals , 0 , sizeof (zend_accel_globals ));
2956
+ accel_globals -> key = zend_string_alloc (ZCG_KEY_LEN , true);
2957
+ }
2958
+
2959
+ #ifdef ZTS
2960
+ static void accel_globals_dtor (zend_accel_globals * accel_globals )
2961
+ {
2962
+ zend_string_free (accel_globals -> key );
2955
2963
}
2964
+ #endif
2956
2965
2957
2966
#ifdef HAVE_HUGE_CODE_PAGES
2958
2967
# ifndef _WIN32
@@ -3128,7 +3137,7 @@ static void accel_move_code_to_huge_pages(void)
3128
3137
static int accel_startup (zend_extension * extension )
3129
3138
{
3130
3139
#ifdef ZTS
3131
- accel_globals_id = ts_allocate_id (& accel_globals_id , sizeof (zend_accel_globals ), (ts_allocate_ctor ) accel_globals_ctor , NULL );
3140
+ 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 );
3132
3141
#else
3133
3142
accel_globals_ctor (& accel_globals );
3134
3143
#endif
0 commit comments