@@ -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
*/
@@ -1198,7 +1200,8 @@ zend_string *accel_make_persistent_key(zend_string *str)
1198
1200
char * key ;
1199
1201
int key_length ;
1200
1202
1201
- ZSTR_LEN (& ZCG (key )) = 0 ;
1203
+ ZEND_ASSERT (GC_REFCOUNT (ZCG (key )) == 1 );
1204
+ ZSTR_LEN (ZCG (key )) = 0 ;
1202
1205
1203
1206
/* CWD and include_path don't matter for absolute file names and streams */
1204
1207
if (IS_ABSOLUTE_PATH (path , path_length )) {
@@ -1308,7 +1311,7 @@ zend_string *accel_make_persistent_key(zend_string *str)
1308
1311
}
1309
1312
1310
1313
/* Calculate key length */
1311
- if (UNEXPECTED ((size_t )(cwd_len + path_length + include_path_len + 2 ) >= sizeof ( ZCG ( _key )) )) {
1314
+ if (UNEXPECTED ((size_t )(cwd_len + path_length + include_path_len + 2 ) >= ZCG_KEY_LEN )) {
1312
1315
return NULL ;
1313
1316
}
1314
1317
@@ -1317,7 +1320,7 @@ zend_string *accel_make_persistent_key(zend_string *str)
1317
1320
* since in itself, it may include colons (which we use to separate
1318
1321
* different components of the key)
1319
1322
*/
1320
- key = ZSTR_VAL (& ZCG (key ));
1323
+ key = ZSTR_VAL (ZCG (key ));
1321
1324
memcpy (key , path , path_length );
1322
1325
key [path_length ] = ':' ;
1323
1326
key_length = path_length + 1 ;
@@ -1341,7 +1344,7 @@ zend_string *accel_make_persistent_key(zend_string *str)
1341
1344
parent_script_len = ZSTR_LEN (parent_script );
1342
1345
while ((-- parent_script_len > 0 ) && !IS_SLASH (ZSTR_VAL (parent_script )[parent_script_len ]));
1343
1346
1344
- if (UNEXPECTED ((size_t )(key_length + parent_script_len + 1 ) >= sizeof ( ZCG ( _key )) )) {
1347
+ if (UNEXPECTED ((size_t )(key_length + parent_script_len + 1 ) >= ZCG_KEY_LEN )) {
1345
1348
return NULL ;
1346
1349
}
1347
1350
key [key_length ] = ':' ;
@@ -1350,11 +1353,9 @@ zend_string *accel_make_persistent_key(zend_string *str)
1350
1353
key_length += parent_script_len ;
1351
1354
}
1352
1355
key [key_length ] = '\0' ;
1353
- GC_SET_REFCOUNT (& ZCG (key ), 1 );
1354
- GC_TYPE_INFO (& ZCG (key )) = GC_STRING ;
1355
- ZSTR_H (& ZCG (key )) = 0 ;
1356
- ZSTR_LEN (& ZCG (key )) = key_length ;
1357
- return & ZCG (key );
1356
+ ZSTR_H (ZCG (key )) = 0 ;
1357
+ ZSTR_LEN (ZCG (key )) = key_length ;
1358
+ return ZCG (key );
1358
1359
}
1359
1360
1360
1361
/* 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 {
@@ -2581,7 +2582,7 @@ static zend_string* persistent_zend_resolve_path(zend_string *filename)
2581
2582
SHM_PROTECT ();
2582
2583
HANDLE_UNBLOCK_INTERRUPTIONS ();
2583
2584
} else {
2584
- ZSTR_LEN (& ZCG (key )) = 0 ;
2585
+ ZSTR_LEN (ZCG (key )) = 0 ;
2585
2586
}
2586
2587
ZCG (cache_opline ) = EG (current_execute_data ) ? EG (current_execute_data )-> opline : NULL ;
2587
2588
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
@@ -3125,7 +3134,7 @@ static void accel_move_code_to_huge_pages(void)
3125
3134
static int accel_startup (zend_extension * extension )
3126
3135
{
3127
3136
#ifdef ZTS
3128
- accel_globals_id = ts_allocate_id (& accel_globals_id , sizeof (zend_accel_globals ), (ts_allocate_ctor ) accel_globals_ctor , NULL );
3137
+ 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 );
3129
3138
#else
3130
3139
accel_globals_ctor (& accel_globals );
3131
3140
#endif
0 commit comments