diff options
author | Wez Furlong <wez@php.net> | 2004-07-28 22:56:01 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2004-07-28 22:56:01 +0000 |
commit | b1667b579b69598ef35f75bef3ec0d2b1fffe4b5 (patch) | |
tree | f99b905131b16f5beb248e0757439bd52eb90b4d /Zend/zend_ini.c | |
parent | b1326c1c24be4d50d7723fa6b142939bf3afcd7f (diff) | |
download | php-git-b1667b579b69598ef35f75bef3ec0d2b1fffe4b5.tar.gz |
Fix: ini entries for dl()'d modules now work under ZTS
Side-effect: avoid possible crashes when multiple threads load/unload
modules and mess with the global hash table.
Diffstat (limited to 'Zend/zend_ini.c')
-rw-r--r-- | Zend/zend_ini.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index 5128a0f8a4..45ff7d9b9c 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -147,10 +147,25 @@ ZEND_API int zend_register_ini_entries(zend_ini_entry *ini_entry, int module_num zend_ini_entry *p = ini_entry; zend_ini_entry *hashed_ini_entry; zval default_value; + HashTable *directives = registered_zend_ini_directives; + +#ifdef ZTS + /* if we are called during the request, eg: from dl(), + * then we should not touch the global directives table, + * and should update the per-(request|thread) version instead. + * This solves two problems: one is that ini entries for dl()'d + * extensions will now work, and the second is that updating the + * global hash here from dl() is not mutex protected and can + * lead to death. + */ + if (directives != EG(ini_directives)) { + directives = EG(ini_directives); + } +#endif while (p->name) { p->module_number = module_number; - if (zend_hash_add(registered_zend_ini_directives, p->name, p->name_length, p, sizeof(zend_ini_entry), (void **) &hashed_ini_entry)==FAILURE) { + if (zend_hash_add(directives, p->name, p->name_length, p, sizeof(zend_ini_entry), (void **) &hashed_ini_entry)==FAILURE) { zend_unregister_ini_entries(module_number TSRMLS_CC); return FAILURE; } |