moriyoshi Mon Feb 21 10:14:02 2005 EDT
Modified files:
/php-src/ext/mbstring mb_gpc.c mbstring.c
/php-src/main SAPI.c SAPI.h main.c php_content_types.c
php_content_types.h
Log:
- Fix bug #28568 (known_post_content_types is not thread safe).
# What is eventually necessiated is entire SAPI redesign, I think.
http://cvs.php.net/diff.php/php-src/ext/mbstring/mb_gpc.c?r1=1.13&r2=1.14&ty=u
Index: php-src/ext/mbstring/mb_gpc.c
diff -u php-src/ext/mbstring/mb_gpc.c:1.13 php-src/ext/mbstring/mb_gpc.c:1.14
--- php-src/ext/mbstring/mb_gpc.c:1.13 Thu Feb 10 09:11:06 2005
+++ php-src/ext/mbstring/mb_gpc.c Mon Feb 21 10:14:01 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mb_gpc.c,v 1.13 2005/02/10 14:11:06 iliaa Exp $ */
+/* $Id: mb_gpc.c,v 1.14 2005/02/21 15:14:01 moriyoshi Exp $ */
/* {{{ includes */
#ifdef HAVE_CONFIG_H
@@ -48,49 +48,22 @@
ZEND_EXTERN_MODULE_GLOBALS(mbstring)
-/* {{{ static sapi_post_entry mbstr_post_entries[] */
-static sapi_post_entry mbstr_post_entries[] = {
- { DEFAULT_POST_CONTENT_TYPE, sizeof(DEFAULT_POST_CONTENT_TYPE)-1,
sapi_read_standard_form_data, php_mb_post_handler },
- { MULTIPART_CONTENT_TYPE, sizeof(MULTIPART_CONTENT_TYPE)-1, NULL,
rfc1867_post_handler },
- { NULL, 0, NULL, NULL }
-};
-/* }}} */
-
-/* {{{ static sapi_post_entry php_post_entries[] */
-static sapi_post_entry php_post_entries[] = {
- { DEFAULT_POST_CONTENT_TYPE, sizeof(DEFAULT_POST_CONTENT_TYPE)-1,
sapi_read_standard_form_data, php_std_post_handler },
- { MULTIPART_CONTENT_TYPE, sizeof(MULTIPART_CONTENT_TYPE)-1, NULL,
rfc1867_post_handler },
- { NULL, 0, NULL, NULL }
-};
-/* }}} */
-
-/* {{{ int _php_mb_enable_encoding_translation(int flag) */
-int _php_mb_enable_encoding_translation(int flag)
-{
- if (flag) {
- sapi_unregister_post_entry(php_post_entries);
- sapi_register_post_entries(mbstr_post_entries);
- sapi_register_treat_data(mbstr_treat_data);
- } else {
- sapi_unregister_post_entry(mbstr_post_entries);
- sapi_register_post_entries(php_post_entries);
- sapi_register_treat_data(php_default_treat_data);
- }
- return SUCCESS;
-}
-/* }}} */
-
/* {{{ MBSTRING_API SAPI_TREAT_DATA_FUNC(mbstr_treat_data)
* http input processing */
MBSTRING_API SAPI_TREAT_DATA_FUNC(mbstr_treat_data)
{
char *res = NULL, *separator=NULL;
const char *c_var;
- pval *array_ptr;
+ zval *array_ptr;
int free_buffer=0;
enum mbfl_no_encoding detected;
php_mb_encoding_handler_info_t info;
+ if (!MBSTRG(encoding_translation)) {
+ php_default_treat_data(arg, str, destArray TSRMLS_CC);
+ return;
+ }
+
switch (arg) {
case PARSE_POST:
case PARSE_GET:
http://cvs.php.net/diff.php/php-src/ext/mbstring/mbstring.c?r1=1.218&r2=1.219&ty=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.218
php-src/ext/mbstring/mbstring.c:1.219
--- php-src/ext/mbstring/mbstring.c:1.218 Mon Feb 21 02:57:07 2005
+++ php-src/ext/mbstring/mbstring.c Mon Feb 21 10:14:01 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mbstring.c,v 1.218 2005/02/21 07:57:07 moriyoshi Exp $ */
+/* $Id: mbstring.c,v 1.219 2005/02/21 15:14:01 moriyoshi Exp $ */
/*
* PHP 4 Multibyte String module "mbstring"
@@ -227,6 +227,14 @@
};
/* }}} */
+/* {{{ static sapi_post_entry php_post_entries[] */
+static sapi_post_entry php_post_entries[] = {
+ { DEFAULT_POST_CONTENT_TYPE, sizeof(DEFAULT_POST_CONTENT_TYPE)-1,
sapi_read_standard_form_data, php_std_post_handler },
+ { MULTIPART_CONTENT_TYPE, sizeof(MULTIPART_CONTENT_TYPE)-1, NULL,
rfc1867_post_handler },
+ { NULL, 0, NULL, NULL }
+};
+/* }}} */
+
ZEND_DECLARE_MODULE_GLOBALS(mbstring)
#ifdef COMPILE_DL_MBSTRING
@@ -283,6 +291,14 @@
};
/* }}} */
+/* {{{ static sapi_post_entry mbstr_post_entries[] */
+static sapi_post_entry mbstr_post_entries[] = {
+ { DEFAULT_POST_CONTENT_TYPE, sizeof(DEFAULT_POST_CONTENT_TYPE)-1,
sapi_read_standard_form_data, php_mb_post_handler },
+ { MULTIPART_CONTENT_TYPE, sizeof(MULTIPART_CONTENT_TYPE)-1, NULL,
rfc1867_post_handler },
+ { NULL, 0, NULL, NULL }
+};
+/* }}} */
+
/* {{{ static int php_mb_parse_encoding_list()
* Return 0 if input contains any illegal encoding, otherwise 1.
* Even if any illegal encoding is detected the result may contain a list
@@ -680,10 +696,13 @@
OnUpdateBool(entry, new_value, new_value_length, mh_arg1, mh_arg2,
mh_arg3, stage TSRMLS_CC);
- if (MBSTRG(encoding_translation)){
- _php_mb_enable_encoding_translation(1);
+ if (MBSTRG(encoding_translation)) {
+ sapi_unregister_post_entry(php_post_entries TSRMLS_CC);
+ sapi_register_post_entries(mbstr_post_entries TSRMLS_CC);
+ sapi_register_treat_data(mbstr_treat_data);
} else {
- _php_mb_enable_encoding_translation(0);
+ sapi_unregister_post_entry(mbstr_post_entries TSRMLS_CC);
+ sapi_register_post_entries(php_post_entries TSRMLS_CC);
}
return SUCCESS;
@@ -774,7 +793,8 @@
REGISTER_INI_ENTRIES();
if (MBSTRG(encoding_translation)) {
- _php_mb_enable_encoding_translation(1);
+ sapi_register_post_entries(mbstr_post_entries TSRMLS_CC);
+ sapi_register_treat_data(mbstr_treat_data);
}
REGISTER_LONG_CONSTANT("MB_OVERLOAD_MAIL", MB_OVERLOAD_MAIL, CONST_CS |
CONST_PERSISTENT);
@@ -809,10 +829,6 @@
free(MBSTRG(detect_order_list));
}
- if (MBSTRG(encoding_translation)) {
- _php_mb_enable_encoding_translation(0);
- }
-
#if HAVE_MBREGEX
PHP_MSHUTDOWN(mb_regex) (INIT_FUNC_ARGS_PASSTHRU);
#endif
http://cvs.php.net/diff.php/php-src/main/SAPI.c?r1=1.192&r2=1.193&ty=u
Index: php-src/main/SAPI.c
diff -u php-src/main/SAPI.c:1.192 php-src/main/SAPI.c:1.193
--- php-src/main/SAPI.c:1.192 Sun Nov 28 08:32:29 2004
+++ php-src/main/SAPI.c Mon Feb 21 10:14:02 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: SAPI.c,v 1.192 2004/11/28 13:32:29 sesser Exp $ */
+/* $Id: SAPI.c,v 1.193 2005/02/21 15:14:02 moriyoshi Exp $ */
#include <ctype.h>
#include <sys/stat.h>
@@ -51,8 +51,6 @@
#include "php_content_types.h"
-static HashTable known_post_content_types;
-
#ifdef ZTS
SAPI_API int sapi_globals_id;
#else
@@ -62,6 +60,13 @@
static void sapi_globals_ctor(sapi_globals_struct *sapi_globals TSRMLS_DC)
{
memset(sapi_globals, 0, sizeof(*sapi_globals));
+ zend_hash_init_ex(&sapi_globals->known_post_content_types, 5,
+ NULL, NULL, 1, 0);
+}
+
+static void sapi_globals_dtor(sapi_globals_struct *sapi_globals TSRMLS_DC)
+{
+ zend_hash_destroy(&sapi_globals->known_post_content_types);
}
/* True globals (no need for thread safety) */
@@ -71,11 +76,11 @@
SAPI_API void sapi_startup(sapi_module_struct *sf)
{
sapi_module = *sf;
- zend_hash_init_ex(&known_post_content_types, 5, NULL, NULL, 1, 0);
#ifdef ZTS
- ts_allocate_id(&sapi_globals_id, sizeof(sapi_globals_struct),
(ts_allocate_ctor) sapi_globals_ctor, NULL);
+ ts_allocate_id(&sapi_globals_id, sizeof(sapi_globals_struct),
(ts_allocate_ctor) sapi_globals_ctor, (ts_allocate_dtor) sapi_globals_dtor);
#else
+ TSRMLS_FETCH();
sapi_globals_ctor(&sapi_globals TSRMLS_CC);
#endif
@@ -90,6 +95,13 @@
SAPI_API void sapi_shutdown(void)
{
+#ifdef ZTS
+ ts_free_id(&sapi_globals_id);
+#else
+ TSRMLS_FETCH();
+ sapi_globals_dtor(&sapi_globals TSRMLS_CC);
+#endif
+
reentrancy_shutdown();
virtual_cwd_shutdown();
@@ -97,8 +109,6 @@
#ifdef PHP_WIN32
tsrm_win32_shutdown();
#endif
-
- zend_hash_destroy(&known_post_content_types);
}
@@ -151,7 +161,8 @@
}
/* now try to find an appropriate POST content handler */
- if (zend_hash_find(&known_post_content_types, content_type,
content_type_length+1, (void **) &post_entry) == SUCCESS) {
+ if (zend_hash_find(&SG(known_post_content_types), content_type,
+ content_type_length+1, (void **) &post_entry) ==
SUCCESS) {
/* found one, register it for use */
SG(request_info).post_entry = post_entry;
post_reader_func = post_entry->post_reader;
@@ -802,12 +813,12 @@
}
-SAPI_API int sapi_register_post_entries(sapi_post_entry *post_entries)
+SAPI_API int sapi_register_post_entries(sapi_post_entry *post_entries
TSRMLS_DC)
{
sapi_post_entry *p=post_entries;
while (p->content_type) {
- if (sapi_register_post_entry(p) == FAILURE) {
+ if (sapi_register_post_entry(p TSRMLS_CC) == FAILURE) {
return FAILURE;
}
p++;
@@ -816,14 +827,17 @@
}
-SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry)
+SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry TSRMLS_DC)
{
- return zend_hash_add(&known_post_content_types,
post_entry->content_type, post_entry->content_type_len+1, (void *) post_entry,
sizeof(sapi_post_entry), NULL);
+ return zend_hash_add(&SG(known_post_content_types),
+ post_entry->content_type,
post_entry->content_type_len+1,
+ (void *) post_entry, sizeof(sapi_post_entry), NULL);
}
-SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry)
+SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry TSRMLS_DC)
{
- zend_hash_del(&known_post_content_types, post_entry->content_type,
post_entry->content_type_len+1);
+ zend_hash_del(&SG(known_post_content_types), post_entry->content_type,
+ post_entry->content_type_len+1);
}
http://cvs.php.net/diff.php/php-src/main/SAPI.h?r1=1.110&r2=1.111&ty=u
Index: php-src/main/SAPI.h
diff -u php-src/main/SAPI.h:1.110 php-src/main/SAPI.h:1.111
--- php-src/main/SAPI.h:1.110 Fri Aug 20 23:09:45 2004
+++ php-src/main/SAPI.h Mon Feb 21 10:14:02 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: SAPI.h,v 1.110 2004/08/21 03:09:45 fmk Exp $ */
+/* $Id: SAPI.h,v 1.111 2005/02/21 15:14:02 moriyoshi Exp $ */
#ifndef SAPI_H
#define SAPI_H
@@ -126,6 +126,7 @@
int options;
zend_bool sapi_started;
time_t global_request_time;
+ HashTable known_post_content_types;
} sapi_globals_struct;
@@ -180,9 +181,9 @@
SAPI_API void sapi_free_header(sapi_header_struct *sapi_header);
SAPI_API void sapi_handle_post(void *arg TSRMLS_DC);
-SAPI_API int sapi_register_post_entries(sapi_post_entry *post_entry);
-SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry);
-SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry);
+SAPI_API int sapi_register_post_entries(sapi_post_entry *post_entry TSRMLS_DC);
+SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry TSRMLS_DC);
+SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry
TSRMLS_DC);
SAPI_API int sapi_register_default_post_reader(void
(*default_post_reader)(TSRMLS_D));
SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str,
zval *destArray TSRMLS_DC));
SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg,
char *var, char **val, unsigned int val_len, unsigned int *new_val_len
TSRMLS_DC));
http://cvs.php.net/diff.php/php-src/main/main.c?r1=1.616&r2=1.617&ty=u
Index: php-src/main/main.c
diff -u php-src/main/main.c:1.616 php-src/main/main.c:1.617
--- php-src/main/main.c:1.616 Sun Jan 9 11:30:09 2005
+++ php-src/main/main.c Mon Feb 21 10:14:02 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: main.c,v 1.616 2005/01/09 16:30:09 sniper Exp $ */
+/* $Id: main.c,v 1.617 2005/02/21 15:14:02 moriyoshi Exp $ */
/* {{{ includes
*/
@@ -1415,7 +1415,7 @@
zuv.import_use_extension = ".php";
php_startup_auto_globals(TSRMLS_C);
zend_set_utility_values(&zuv);
- php_startup_sapi_content_types();
+ php_startup_sapi_content_types(TSRMLS_C);
REGISTER_MAIN_STRINGL_CONSTANT("PHP_VERSION", PHP_VERSION,
sizeof(PHP_VERSION)-1, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_STRINGL_CONSTANT("PHP_OS", php_os, strlen(php_os),
CONST_PERSISTENT | CONST_CS);
http://cvs.php.net/diff.php/php-src/main/php_content_types.c?r1=1.29&r2=1.30&ty=u
Index: php-src/main/php_content_types.c
diff -u php-src/main/php_content_types.c:1.29
php-src/main/php_content_types.c:1.30
--- php-src/main/php_content_types.c:1.29 Thu Jan 8 03:17:53 2004
+++ php-src/main/php_content_types.c Mon Feb 21 10:14:02 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_content_types.c,v 1.29 2004/01/08 08:17:53 andi Exp $ */
+/* $Id: php_content_types.c,v 1.30 2005/02/21 15:14:02 moriyoshi Exp $ */
#include "php.h"
#include "SAPI.h"
@@ -72,9 +72,9 @@
/* {{{ php_startup_sapi_content_types
*/
-int php_startup_sapi_content_types(void)
+int php_startup_sapi_content_types(TSRMLS_D)
{
- sapi_register_post_entries(php_post_entries);
+ sapi_register_post_entries(php_post_entries TSRMLS_CC);
sapi_register_default_post_reader(php_default_post_reader);
sapi_register_treat_data(php_default_treat_data);
sapi_register_input_filter(php_default_input_filter);
http://cvs.php.net/diff.php/php-src/main/php_content_types.h?r1=1.9&r2=1.10&ty=u
Index: php-src/main/php_content_types.h
diff -u php-src/main/php_content_types.h:1.9
php-src/main/php_content_types.h:1.10
--- php-src/main/php_content_types.h:1.9 Thu Jan 8 12:33:04 2004
+++ php-src/main/php_content_types.h Mon Feb 21 10:14:02 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_content_types.h,v 1.9 2004/01/08 17:33:04 sniper Exp $ */
+/* $Id: php_content_types.h,v 1.10 2005/02/21 15:14:02 moriyoshi Exp $ */
#ifndef PHP_CONTENT_TYPES_H
#define PHP_CONTENT_TYPES_H
@@ -25,6 +25,6 @@
SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader);
SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler);
-int php_startup_sapi_content_types(void);
+int php_startup_sapi_content_types(TSRMLS_D);
#endif /* PHP_CONTENT_TYPES_H */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php