diff options
author | Zeev Suraski <zeev@php.net> | 2001-07-28 11:36:37 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 2001-07-28 11:36:37 +0000 |
commit | d87cc976e1156b839fc6d4aa6b473a126802b8e3 (patch) | |
tree | 8acb068dd7458e1c8df3a7d8ecb87d065990fdb1 /main/SAPI.c | |
parent | b4f3b9d3ce9f55cf040fb5aa8f201c64646cab43 (diff) | |
download | php-git-d87cc976e1156b839fc6d4aa6b473a126802b8e3.tar.gz |
Redesigned thread safety mechanism - nua nua
Diffstat (limited to 'main/SAPI.c')
-rw-r--r-- | main/SAPI.c | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/main/SAPI.c b/main/SAPI.c index 466e673de3..618f16f140 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -50,7 +50,7 @@ sapi_globals_struct sapi_globals; static void sapi_globals_ctor(sapi_globals_struct *sapi_globals TSRMLS_DC) { - memset(sapi_globals,0,sizeof(*sapi_globals)); + memset(sapi_globals, 0, sizeof(*sapi_globals)); } /* True globals (no need for thread safety) */ @@ -101,10 +101,10 @@ SAPI_API void sapi_free_header(sapi_header_struct *sapi_header) } -SAPI_API void sapi_handle_post(void *arg SLS_DC) +SAPI_API void sapi_handle_post(void *arg TSRMLS_DC) { if (SG(request_info).post_entry && SG(request_info).content_type_dup) { - SG(request_info).post_entry->post_handler(SG(request_info).content_type_dup, arg SLS_CC); + SG(request_info).post_entry->post_handler(SG(request_info).content_type_dup, arg TSRMLS_CC); if (SG(request_info).post_data) { efree(SG(request_info).post_data); SG(request_info).post_data = NULL; @@ -114,15 +114,14 @@ SAPI_API void sapi_handle_post(void *arg SLS_DC) } } -static void sapi_read_post_data(SLS_D) +static void sapi_read_post_data(TSRMLS_D) { sapi_post_entry *post_entry; uint content_type_length = strlen(SG(request_info).content_type); char *content_type = estrndup(SG(request_info).content_type, content_type_length); char *p; char oldchar=0; - void (*post_reader_func)(SLS_D); - PLS_FETCH(); + void (*post_reader_func)(TSRMLS_D); /* dedicated implementation for increased performance: @@ -158,10 +157,10 @@ static void sapi_read_post_data(SLS_D) if (oldchar) { *(p-1) = oldchar; } - post_reader_func(SLS_C); + post_reader_func(TSRMLS_C); SG(request_info).content_type_dup = content_type; if(PG(always_populate_raw_post_data) && sapi_module.default_post_reader) { - sapi_module.default_post_reader(SLS_C); + sapi_module.default_post_reader(TSRMLS_C); } } @@ -179,7 +178,7 @@ SAPI_POST_READER_FUNC(sapi_read_standard_form_data) SG(request_info).post_data = emalloc(allocated_bytes); for (;;) { - read_bytes = sapi_module.read_post(SG(request_info).post_data+SG(read_post_bytes), SAPI_POST_BLOCK_SIZE SLS_CC); + read_bytes = sapi_module.read_post(SG(request_info).post_data+SG(read_post_bytes), SAPI_POST_BLOCK_SIZE TSRMLS_CC); if (read_bytes<=0) { break; } @@ -201,7 +200,7 @@ SAPI_POST_READER_FUNC(sapi_read_standard_form_data) } -SAPI_API char *sapi_get_default_content_type(SLS_D) +SAPI_API char *sapi_get_default_content_type(TSRMLS_D) { char *mimetype, *charset, *content_type; @@ -219,9 +218,9 @@ SAPI_API char *sapi_get_default_content_type(SLS_D) } -SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header SLS_DC) +SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header TSRMLS_DC) { - char *default_content_type = sapi_get_default_content_type(SLS_C); + char *default_content_type = sapi_get_default_content_type(TSRMLS_C); int default_content_type_len = strlen(default_content_type); default_header->header_len = (sizeof("Content-type: ")-1) + default_content_type_len; @@ -243,7 +242,7 @@ SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_h * unchanged, 0 is returned. * */ -SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len SLS_DC) +SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len TSRMLS_DC) { char *charset, *newtype; size_t newlen; @@ -267,7 +266,7 @@ SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len SLS_DC) /* * Called from php_request_startup() for every request. */ -SAPI_API void sapi_activate(SLS_D) +SAPI_API void sapi_activate(TSRMLS_D) { zend_llist_init(&SG(sapi_headers).headers, sizeof(sapi_header_struct), (void (*)(void *)) sapi_free_header, 0); SG(sapi_headers).send_default_content_type = 1; @@ -300,20 +299,20 @@ SAPI_API void sapi_activate(SLS_D) sapi_module.sapi_error(E_WARNING, "No content-type in POST request"); SG(request_info).content_type_dup = NULL; } else { - sapi_read_post_data(SLS_C); + sapi_read_post_data(TSRMLS_C); } } else { SG(request_info).content_type_dup = NULL; } - SG(request_info).cookie_data = sapi_module.read_cookies(SLS_C); + SG(request_info).cookie_data = sapi_module.read_cookies(TSRMLS_C); if (sapi_module.activate) { - sapi_module.activate(SLS_C); + sapi_module.activate(TSRMLS_C); } } } -SAPI_API void sapi_deactivate(SLS_D) +SAPI_API void sapi_deactivate(TSRMLS_D) { zend_llist_destroy(&SG(sapi_headers).headers); if (SG(request_info).post_data) { @@ -332,15 +331,15 @@ SAPI_API void sapi_deactivate(SLS_D) efree(SG(request_info).current_user); } if (sapi_module.deactivate) { - sapi_module.deactivate(SLS_C); + sapi_module.deactivate(TSRMLS_C); } if (SG(rfc1867_uploaded_files)) { - destroy_uploaded_files_hash(SLS_C); + destroy_uploaded_files_hash(TSRMLS_C); } } -SAPI_API void sapi_initialize_empty_request(SLS_D) +SAPI_API void sapi_initialize_empty_request(TSRMLS_D) { SG(server_context) = NULL; SG(request_info).request_method = NULL; @@ -372,7 +371,7 @@ SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bo int retval, free_header = 0; sapi_header_struct sapi_header; char *colon_offset; - SLS_FETCH(); + TSRMLS_FETCH(); if (SG(headers_sent) && !SG(request_info).no_headers) { char *output_start_filename = php_get_output_start_filename(); @@ -421,7 +420,7 @@ SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bo ptr++; } mimetype = estrdup(ptr); - newlen = sapi_apply_default_charset(&mimetype, len SLS_CC); + newlen = sapi_apply_default_charset(&mimetype, len TSRMLS_CC); if (newlen != 0) { newlen += sizeof("Content-type: "); newheader = emalloc(newlen); @@ -449,7 +448,7 @@ SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bo } if (sapi_module.header_handler) { - retval = sapi_module.header_handler(&sapi_header, &SG(sapi_headers) SLS_CC); + retval = sapi_module.header_handler(&sapi_header, &SG(sapi_headers) TSRMLS_CC); } else { retval = SAPI_HEADER_ADD; } @@ -470,7 +469,7 @@ SAPI_API int sapi_send_headers() { int retval; int ret = FAILURE; - SLS_FETCH(); + TSRMLS_FETCH(); if (SG(headers_sent) || SG(request_info).no_headers) { return SUCCESS; @@ -482,7 +481,7 @@ SAPI_API int sapi_send_headers() SG(headers_sent) = 1; if (sapi_module.send_headers) { - retval = sapi_module.send_headers(&SG(sapi_headers) SLS_CC); + retval = sapi_module.send_headers(&SG(sapi_headers) TSRMLS_CC); } else { retval = SAPI_HEADER_DO_SEND; } @@ -503,7 +502,7 @@ SAPI_API int sapi_send_headers() if(SG(sapi_headers).send_default_content_type) { sapi_header_struct default_header; - sapi_get_default_content_type_header(&default_header SLS_CC); + sapi_get_default_content_type_header(&default_header TSRMLS_CC); sapi_module.send_header(&default_header, SG(server_context)); sapi_free_header(&default_header); } @@ -549,7 +548,7 @@ SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry) } -SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(SLS_D)) +SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(TSRMLS_D)) { sapi_module.default_post_reader = default_post_reader; return SUCCESS; @@ -559,7 +558,7 @@ SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(SLS_D SAPI_API int sapi_flush() { if (sapi_module.flush) { - SLS_FETCH(); + TSRMLS_FETCH(); sapi_module.flush(SG(server_context)); return SUCCESS; @@ -570,10 +569,10 @@ SAPI_API int sapi_flush() SAPI_API struct stat *sapi_get_stat() { - SLS_FETCH(); + TSRMLS_FETCH(); if (sapi_module.get_stat) { - return sapi_module.get_stat(SLS_C); + return sapi_module.get_stat(TSRMLS_C); } else { if (!SG(request_info).path_translated || (VCWD_STAT(SG(request_info).path_translated, &SG(global_stat))==-1)) { return NULL; @@ -586,9 +585,9 @@ SAPI_API struct stat *sapi_get_stat() SAPI_API char *sapi_getenv(char *name, size_t name_len) { if (sapi_module.getenv) { - SLS_FETCH(); + TSRMLS_FETCH(); - return sapi_module.getenv(name, name_len SLS_CC); + return sapi_module.getenv(name, name_len TSRMLS_CC); } else { return NULL; } |