summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>1999-08-13 21:03:27 +0000
committerZeev Suraski <zeev@php.net>1999-08-13 21:03:27 +0000
commit58e24ac18a06944791cebf606042e92128abc7b7 (patch)
treeb37103a4c8ec02a83bb0230211d68188ceadfcdb /main
parent5ae3f32b24b45512c96e89ff3162725ddef09cc8 (diff)
downloadphp-git-58e24ac18a06944791cebf606042e92128abc7b7.tar.gz
- Add PHP Modules workspace
- Get the MySQL module to compile&work under thread-safe Win32 - Fix various thread safety issues with dynamic modules
Diffstat (limited to 'main')
-rw-r--r--main/main.c26
-rw-r--r--main/php_ini.c15
-rw-r--r--main/php_ini.h5
3 files changed, 31 insertions, 15 deletions
diff --git a/main/main.c b/main/main.c
index 15fa76ac65..63f0519f21 100644
--- a/main/main.c
+++ b/main/main.c
@@ -96,9 +96,6 @@ void *gLock; /*mutex variable */
/* True globals (no need for thread safety) */
HashTable configuration_hash;
PHPAPI char *php3_ini_path = NULL;
-#ifdef ZTS
-php_core_globals *main_core_globals=NULL;
-#endif
#define SAFE_FILENAME(f) ((f)?(f):"-")
@@ -755,20 +752,17 @@ static void php3_config_ini_shutdown()
}
-#ifdef ZTS
-static void core_globals_ctor(php_core_globals *core_globals)
+static int zend_body_write_wrapper(const char *str, uint str_length)
{
- if (main_core_globals) {
- *core_globals = *main_core_globals;
- }
+ return zend_body_write(str, str_length);
}
-#endif
-
-static int zend_body_write_wrapper(const char *str, uint str_length)
+#ifdef ZTS
+static void php_new_thread_end_handler(THREAD_T thread_id)
{
- return zend_body_write(str, str_length);
+ php_ini_refresh_caches();
}
+#endif
int php_module_startup(sapi_module_struct *sf)
@@ -810,10 +804,11 @@ int php_module_startup(sapi_module_struct *sf)
zuf.get_ini_entry = php_get_ini_entry_for_zend;
zend_startup(&zuf, NULL);
+ tsrm_set_new_thread_end_handler(php_new_thread_end_handler);
+
#ifdef ZTS
- core_globals_id = ts_allocate_id(sizeof(php_core_globals), core_globals_ctor, NULL);
+ core_globals_id = ts_allocate_id(sizeof(php_core_globals), NULL, NULL);
core_globals = ts_resource(core_globals_id);
- main_core_globals = core_globals;
#endif
PG(header_is_being_sent) = 0;
@@ -835,11 +830,12 @@ int php_module_startup(sapi_module_struct *sf)
le_index_ptr = _register_list_destructors(NULL, NULL, 0);
FREE_MUTEX(gLock);
+ php_ini_mstartup();
+
if (php3_config_ini_startup() == FAILURE) {
return FAILURE;
}
- php_ini_mstartup();
REGISTER_INI_ENTRIES();
zuv.short_tags = (unsigned char) PG(short_tags);
diff --git a/main/php_ini.c b/main/php_ini.c
index 4c25faf5b8..bd73ef6b58 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -125,6 +125,21 @@ PHPAPI void php_unregister_ini_entries(int module_number)
}
+static int php_ini_refresh_cache(php_ini_entry *p)
+{
+ if (p->on_modify) {
+ p->on_modify(p, p->value, p->value_length, p->mh_arg1, p->mh_arg2, p->mh_arg3);
+ }
+ return 0;
+}
+
+
+PHPAPI void php_ini_refresh_caches()
+{
+ zend_hash_apply(&known_directives, (int (*)(void *)) php_ini_refresh_cache);
+}
+
+
PHPAPI int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type)
{
php_ini_entry *ini_entry;
diff --git a/main/php_ini.h b/main/php_ini.h
index 4ccd84c46e..4dfd0b40bd 100644
--- a/main/php_ini.h
+++ b/main/php_ini.h
@@ -57,6 +57,7 @@ int php_ini_rshutdown();
PHPAPI int php_register_ini_entries(php_ini_entry *ini_entry, int module_number);
PHPAPI void php_unregister_ini_entries(int module_number);
+PHPAPI void php_ini_refresh_caches();
PHPAPI int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type);
PHPAPI int php_restore_ini_entry(char *name, uint name_length);
PHPAPI void display_ini_entries(zend_module_entry *module);
@@ -100,11 +101,15 @@ PHPAPI PHP_INI_DISP(php_ini_color_displayer_cb);
#ifdef ZTS
#define STD_PHP_INI_ENTRY(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
PHP_INI_ENTRY2(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id)
+#define STD_PHP_INI_ENTRY_EX(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr, displayer) \
+ PHP_INI_ENTRY2_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id, displayer)
#define STD_PHP_INI_BOOLEAN(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
PHP_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id, NULL, php_ini_boolean_displayer_cb)
#else
#define STD_PHP_INI_ENTRY(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
PHP_INI_ENTRY2(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr)
+#define STD_PHP_INI_ENTRY_EX(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr, display) \
+ PHP_INI_ENTRY2_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, displayer)
#define STD_PHP_INI_BOOLEAN(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
PHP_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, NULL, php_ini_boolean_displayer_cb)
#endif