From a07b79b1871054ca17e48b69445b4dc201f24662 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Sun, 12 Jun 2011 08:14:46 +0000 Subject: [PATCH] thread safety --- php_http.h | 4 +-- php_http_cookie.c | 65 ++++++++++++++++++++---------------- php_http_cookie.h | 23 ++++++++----- php_http_curl.c | 34 ++++++++++++------- php_http_encoding.c | 9 +++-- php_http_env.c | 6 ++-- php_http_env_response.c | 21 ++++++------ php_http_env_response.h | 2 +- php_http_etag.c | 60 ++++++++++++++++++--------------- php_http_etag.h | 15 +++++++-- php_http_filter.c | 12 +++---- php_http_header_parser.c | 2 +- php_http_message.c | 26 ++++++++------- php_http_message_body.c | 26 ++++++++++----- php_http_message_body.h | 2 +- php_http_message_parser.c | 10 +++--- php_http_misc.c | 4 +-- php_http_neon.c | 13 +++++--- php_http_params.c | 9 ++--- php_http_persistent_handle.c | 3 +- php_http_request.c | 6 ++-- php_http_request_datashare.c | 9 ++--- php_http_request_factory.c | 8 ++--- php_http_request_method.c | 2 +- php_http_request_method.h | 2 +- php_http_request_pool.c | 6 ++-- php_http_url.c | 2 +- 27 files changed, 217 insertions(+), 164 deletions(-) diff --git a/php_http.h b/php_http.h index b1bc57c..7c966fc 100644 --- a/php_http.h +++ b/php_http.h @@ -128,9 +128,9 @@ ZEND_EXTERN_MODULE_GLOBALS(php_http); #ifdef ZTS # include "TSRM/TSRM.h" -# define PHP_HTTP_G ((php_http_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(php_http_globals_id)]) +# define PHP_HTTP_G ((zend_php_http_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(php_http_globals_id)]) # undef TSRMLS_FETCH_FROM_CTX -# define TSRMLS_FETCH_FROM_CTX(ctx) ((ctx)?(ctx):ts_resource_ex(0, NULL)) +# define TSRMLS_FETCH_FROM_CTX(ctx) void ***tsrm_ls = ((ctx)?(ctx):ts_resource_ex(0, NULL)) #else # define PHP_HTTP_G (&php_http_globals) #endif diff --git a/php_http_cookie.c b/php_http_cookie.c index 6c2a3d4..cf5e56c 100644 --- a/php_http_cookie.c +++ b/php_http_cookie.c @@ -30,11 +30,15 @@ PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_init(php_http_cookie_l list->expires = 0; list->flags = 0; + TSRMLS_SET_CTX(list->ts); + return list; } -PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_copy(php_http_cookie_list_t *from, php_http_cookie_list_t *to TSRMLS_DC) +PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_copy(php_http_cookie_list_t *from, php_http_cookie_list_t *to) { + TSRMLS_FETCH_FROM_CTX(from->ts); + to = php_http_cookie_list_init(to TSRMLS_CC); array_copy(&from->cookies, &to->cookies); @@ -48,7 +52,7 @@ PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_copy(php_http_cookie_l return to; } -PHP_HTTP_API void php_http_cookie_list_dtor(php_http_cookie_list_t *list TSRMLS_DC) +PHP_HTTP_API void php_http_cookie_list_dtor(php_http_cookie_list_t *list) { if (list) { zend_hash_destroy(&list->cookies); @@ -61,7 +65,7 @@ PHP_HTTP_API void php_http_cookie_list_dtor(php_http_cookie_list_t *list TSRMLS_ -PHP_HTTP_API void php_http_cookie_list_free(php_http_cookie_list_t **list TSRMLS_DC) +PHP_HTTP_API void php_http_cookie_list_free(php_http_cookie_list_t **list) { if (*list) { php_http_cookie_list_dtor(*list); @@ -72,7 +76,7 @@ PHP_HTTP_API void php_http_cookie_list_free(php_http_cookie_list_t **list TSRMLS -PHP_HTTP_API const char *php_http_cookie_list_get_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len TSRMLS_DC) +PHP_HTTP_API const char *php_http_cookie_list_get_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len) { zval **cookie = NULL; if ((SUCCESS != zend_hash_find(&list->cookies, name, name_len + 1, (void *) &cookie)) || (Z_TYPE_PP(cookie) != IS_STRING)) { @@ -83,7 +87,7 @@ PHP_HTTP_API const char *php_http_cookie_list_get_cookie(php_http_cookie_list_t -PHP_HTTP_API const char *php_http_cookie_list_get_extra(php_http_cookie_list_t *list, const char *name, size_t name_len TSRMLS_DC) +PHP_HTTP_API const char *php_http_cookie_list_get_extra(php_http_cookie_list_t *list, const char *name, size_t name_len) { zval **extra = NULL; if ((SUCCESS != zend_hash_find(&list->extras, name, name_len + 1, (void *) &extra)) || (Z_TYPE_PP(extra) != IS_STRING)) { @@ -94,26 +98,24 @@ PHP_HTTP_API const char *php_http_cookie_list_get_extra(php_http_cookie_list_t * -PHP_HTTP_API void php_http_cookie_list_add_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len, const char *value, size_t value_len TSRMLS_DC) +PHP_HTTP_API void php_http_cookie_list_add_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len, const char *value, size_t value_len) { zval *cookie_value; - char *key = estrndup(name, name_len); + MAKE_STD_ZVAL(cookie_value); ZVAL_STRINGL(cookie_value, estrndup(value, value_len), value_len, 0); - zend_hash_update(&list->cookies, key, name_len + 1, (void *) &cookie_value, sizeof(zval *), NULL); - efree(key); + zend_hash_update(&list->cookies, name, name_len + 1, (void *) &cookie_value, sizeof(zval *), NULL); } -PHP_HTTP_API void php_http_cookie_list_add_extra(php_http_cookie_list_t *list, const char *name, size_t name_len, const char *value, size_t value_len TSRMLS_DC) +PHP_HTTP_API void php_http_cookie_list_add_extra(php_http_cookie_list_t *list, const char *name, size_t name_len, const char *value, size_t value_len) { zval *cookie_value; - char *key = estrndup(name, name_len); + MAKE_STD_ZVAL(cookie_value); ZVAL_STRINGL(cookie_value, estrndup(value, value_len), value_len, 0); - zend_hash_update(&list->extras, key, name_len + 1, (void *) &cookie_value, sizeof(zval *), NULL); - efree(key); + zend_hash_update(&list->extras, name, name_len + 1, (void *) &cookie_value, sizeof(zval *), NULL); } @@ -135,7 +137,7 @@ static void php_http_cookie_parse_callback(void *ptr, const char *key, int keyle STR_SET(arg->list->domain, estrndup(val, vallen)); } else if _KEY_IS("expires") { char *date = estrndup(val, vallen); - arg->list->expires = php_parse_date(date, NULL TSRMLS_CC); + arg->list->expires = php_parse_date(date, NULL); efree(date); } else if _KEY_IS("secure") { arg->list->flags |= PHP_HTTP_COOKIE_SECURE; @@ -149,12 +151,12 @@ static void php_http_cookie_parse_callback(void *ptr, const char *key, int keyle for (; *ae; ++ae) { if ((size_t) keylen == strlen(*ae) && !strncasecmp(key, *ae, keylen)) { if (arg->flags & PHP_HTTP_COOKIE_PARSE_RAW) { - php_http_cookie_list_add_extra(arg->list, key, keylen, val, vallen TSRMLS_CC); + php_http_cookie_list_add_extra(arg->list, key, keylen, val, vallen); } else { char *dec = estrndup(val, vallen); int declen = php_url_decode(dec, vallen); - php_http_cookie_list_add_extra(arg->list, key, keylen, dec, declen TSRMLS_CC); + php_http_cookie_list_add_extra(arg->list, key, keylen, dec, declen); efree(dec); } return; @@ -163,12 +165,12 @@ static void php_http_cookie_parse_callback(void *ptr, const char *key, int keyle } /* new cookie */ if (arg->flags & PHP_HTTP_COOKIE_PARSE_RAW) { - php_http_cookie_list_add_cookie(arg->list, key, keylen, val, vallen TSRMLS_CC); + php_http_cookie_list_add_cookie(arg->list, key, keylen, val, vallen); } else { char *dec = estrndup(val, vallen); int declen = php_url_decode(dec, vallen); - php_http_cookie_list_add_cookie(arg->list, key, keylen, dec, declen TSRMLS_CC); + php_http_cookie_list_add_cookie(arg->list, key, keylen, dec, declen); efree(dec); } } @@ -189,9 +191,9 @@ PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_parse(php_http_cookie_ if (SUCCESS != php_http_params_parse(string, PHP_HTTP_PARAMS_RAISE_ERROR, php_http_cookie_parse_callback, &arg TSRMLS_CC)) { if (free_list) { - php_http_cookie_list_free(&list TSRMLS_CC); + php_http_cookie_list_free(&list); } else { - php_http_cookie_list_dtor(list TSRMLS_CC); + php_http_cookie_list_dtor(list); } list = NULL; } @@ -201,9 +203,10 @@ PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_parse(php_http_cookie_ -PHP_HTTP_API void php_http_cookie_list_to_struct(php_http_cookie_list_t *list, zval *strct TSRMLS_DC) +PHP_HTTP_API void php_http_cookie_list_to_struct(php_http_cookie_list_t *list, zval *strct) { zval array, *cookies, *extras; + TSRMLS_FETCH_FROM_CTX(list->ts); INIT_PZVAL_ARRAY(&array, HASH_OF(strct)); @@ -266,7 +269,7 @@ PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_from_struct(php_http_c if (Z_LVAL_P(cpy)) { list->expires = Z_LVAL_P(cpy); } else { - time_t expires = php_parse_date(Z_STRVAL_PP(tmp), NULL TSRMLS_CC); + time_t expires = php_parse_date(Z_STRVAL_PP(tmp), NULL); if (expires > 0) { list->expires = expires; } @@ -308,12 +311,13 @@ static inline void append_encoded(php_http_buffer_t *buf, const char *key, size_ -PHP_HTTP_API void php_http_cookie_list_to_string(php_http_cookie_list_t *list, char **str, size_t *len TSRMLS_DC) +PHP_HTTP_API void php_http_cookie_list_to_string(php_http_cookie_list_t *list, char **str, size_t *len) { php_http_buffer_t buf; zval **val; php_http_array_hashkey_t key = php_http_array_hashkey_init(0); HashPosition pos; + TSRMLS_FETCH_FROM_CTX(list->ts); php_http_buffer_init(&buf); @@ -486,22 +490,25 @@ zend_object_value php_http_cookie_object_new_ex(zend_class_entry *ce, php_http_c return ov; } -zend_object_value php_http_cookie_object_clone(zval *this_ptr TSRMLS_CC) +zend_object_value php_http_cookie_object_clone(zval *this_ptr TSRMLS_DC) { php_http_cookie_object_t *new_obj, *old_obj = zend_object_store_get_object(getThis() TSRMLS_CC); zend_object_value ov; - ov = php_http_cookie_object_new_ex(old_obj->o.ce, php_http_cookie_list_copy(old_obj->list, NULL TSRMLS_CC), &new_obj TSRMLS_CC); + if (!old_obj->list) { + old_obj->list = php_http_cookie_list_init(NULL TSRMLS_CC); + } + ov = php_http_cookie_object_new_ex(old_obj->o.ce, php_http_cookie_list_copy(old_obj->list, NULL), &new_obj TSRMLS_CC); zend_objects_clone_members((zend_object *) new_obj, ov, (zend_object *) old_obj, Z_OBJ_HANDLE_P(getThis()) TSRMLS_CC); return ov; } -void php_http_cookie_object_free(void *object TSRMLS_CC) +void php_http_cookie_object_free(void *object TSRMLS_DC) { php_http_cookie_object_t *obj = object; - php_http_cookie_list_free(&obj->list TSRMLS_CC); + php_http_cookie_list_free(&obj->list); zend_object_std_dtor((zend_object *) obj TSRMLS_CC); efree(obj); } @@ -904,7 +911,7 @@ PHP_METHOD(HttpCookie, toString) if (!obj->list) { obj->list = php_http_cookie_list_init(NULL TSRMLS_CC); } - php_http_cookie_list_to_string(obj->list, &str, &len TSRMLS_CC); + php_http_cookie_list_to_string(obj->list, &str, &len); RETURN_STRINGL(str, len, 0); } RETURN_EMPTY_STRING(); @@ -919,7 +926,7 @@ PHP_METHOD(HttpCookie, toArray) obj->list = php_http_cookie_list_init(NULL TSRMLS_CC); } array_init(return_value); - php_http_cookie_list_to_struct(obj->list, return_value TSRMLS_CC); + php_http_cookie_list_to_struct(obj->list, return_value); } } diff --git a/php_http_cookie.h b/php_http_cookie.h index 1e2b0f7..9307358 100644 --- a/php_http_cookie.h +++ b/php_http_cookie.h @@ -32,24 +32,29 @@ typedef struct php_http_cookie_list { char *path; char *domain; time_t expires; + +#ifdef ZTS + void ***ts; +#endif } php_http_cookie_list_t; PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_init(php_http_cookie_list_t *list TSRMLS_DC); -PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_parse(php_http_cookie_list_t * list, const char *string, long flags, char **allowed_extras TSRMLS_DC); -PHP_HTTP_API void php_http_cookie_list_dtor(php_http_cookie_list_t *list TSRMLS_DC); -PHP_HTTP_API void php_http_cookie_list_free(php_http_cookie_list_t **list TSRMLS_DC); +PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_parse(php_http_cookie_list_t *list, const char *string, long flags, char **allowed_extras TSRMLS_DC); +PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_copy(php_http_cookie_list_t *from, php_http_cookie_list_t *to); +PHP_HTTP_API void php_http_cookie_list_dtor(php_http_cookie_list_t *list); +PHP_HTTP_API void php_http_cookie_list_free(php_http_cookie_list_t **list); #define php_http_cookie_list_has_cookie(list, name, name_len) zend_hash_exists(&(list)->cookies, (name), (name_len)+1) -PHP_HTTP_API void php_http_cookie_list_add_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len, const char *value, size_t value_len TSRMLS_DC); -PHP_HTTP_API const char *php_http_cookie_list_get_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len TSRMLS_DC); +PHP_HTTP_API void php_http_cookie_list_add_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len, const char *value, size_t value_len); +PHP_HTTP_API const char *php_http_cookie_list_get_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len); #define php_http_cookie_list_has_extra(list, name, name_len) zend_hash_exists(&(list)->extras, (name), (name_len)+1) -PHP_HTTP_API void php_http_cookie_list_add_extra(php_http_cookie_list_t *list, const char *name, size_t name_len, const char *value, size_t value_len TSRMLS_DC); -PHP_HTTP_API const char *php_http_cookie_list_get_extra(php_http_cookie_list_t *list, const char *name, size_t name_len TSRMLS_DC); +PHP_HTTP_API void php_http_cookie_list_add_extra(php_http_cookie_list_t *list, const char *name, size_t name_len, const char *value, size_t value_len); +PHP_HTTP_API const char *php_http_cookie_list_get_extra(php_http_cookie_list_t *list, const char *name, size_t name_len); -PHP_HTTP_API void php_http_cookie_list_to_string(php_http_cookie_list_t *list, char **str, size_t *len TSRMLS_DC); +PHP_HTTP_API void php_http_cookie_list_to_string(php_http_cookie_list_t *list, char **str, size_t *len); PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_from_struct(php_http_cookie_list_t *list, zval *strct TSRMLS_DC); -PHP_HTTP_API void php_http_cookie_list_to_struct(php_http_cookie_list_t *list, zval *strct TSRMLS_DC); +PHP_HTTP_API void php_http_cookie_list_to_struct(php_http_cookie_list_t *list, zval *strct); extern zend_class_entry *php_http_cookie_class_entry; diff --git a/php_http_curl.c b/php_http_curl.c index 71365dc..ae8eb55 100644 --- a/php_http_curl.c +++ b/php_http_curl.c @@ -227,6 +227,7 @@ static int php_http_curl_raw_callback(CURL *ch, curl_infotype type, char *data, php_http_request_t *h = ctx; php_http_curl_request_t *curl = h->ctx; unsigned flags = 0; + TSRMLS_FETCH_FROM_CTX(h->ts); /* catch progress */ switch (type) { @@ -322,7 +323,7 @@ static STATUS php_http_curl_request_prepare(php_http_request_t *h, php_http_requ break; default: { - const char *name = php_http_request_method_name(meth); + const char *name = php_http_request_method_name(meth TSRMLS_CC); if (name) { curl_easy_setopt(curl->handle, CURLOPT_CUSTOMREQUEST, name); @@ -591,6 +592,7 @@ static STATUS set_options(php_http_request_t *h, HashTable *options) int range_req = 0; php_http_curl_request_t *curl = h->ctx; CURL *ch = curl->handle; + TSRMLS_FETCH_FROM_CTX(h->ts); /* proxy */ if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("proxyhost"), IS_STRING))) { @@ -1187,9 +1189,10 @@ static void php_http_curl_request_datashare_unlock_func(CURL *handle, curl_lock_ /* request datashare handler ops */ -static php_http_request_datashare_t *php_http_curl_request_datashare_init(php_http_request_datashare_t *h, void *handle TSRMLS_DC) +static php_http_request_datashare_t *php_http_curl_request_datashare_init(php_http_request_datashare_t *h, void *handle) { php_http_curl_request_datashare_t *curl; + TSRMLS_FETCH_FROM_CTX(h->ts); if (!handle && !(handle = php_http_resource_factory_handle_ctor(h->rf TSRMLS_CC))) { php_http_error(HE_WARNING, PHP_HTTP_E_REQUEST_DATASHARE, "could not initialize curl share handle"); @@ -1200,11 +1203,11 @@ static php_http_request_datashare_t *php_http_curl_request_datashare_init(php_ht curl->handle = handle; #ifdef ZTS if (h->persistent) { - curl->locks = php_http_request_datashare_locks_init(); + curl->locks = php_http_curl_request_datashare_locks_init(); if (curl->locks) { - curl_share_setopt(share->ch, CURLSHOPT_LOCKFUNC, php_http_curl_request_datashare_lock_func); - curl_share_setopt(share->ch, CURLSHOPT_UNLOCKFUNC, php_http_curl_request_datashare_unlock_func); - curl_share_setopt(share->ch, CURLSHOPT_USERDATA, curl->locks); + curl_share_setopt(curl->handle, CURLSHOPT_LOCKFUNC, php_http_curl_request_datashare_lock_func); + curl_share_setopt(curl->handle, CURLSHOPT_UNLOCKFUNC, php_http_curl_request_datashare_unlock_func); + curl_share_setopt(curl->handle, CURLSHOPT_USERDATA, curl->locks); } } #endif @@ -1222,7 +1225,7 @@ static void php_http_curl_request_datashare_dtor(php_http_request_datashare_t *h #ifdef ZTS if (h->persistent) { - http_request_datashare_locks_dtor(curl->locks); + php_http_curl_request_datashare_locks_dtor(curl->locks); } #endif @@ -1314,9 +1317,10 @@ PHP_HTTP_API php_http_request_datashare_ops_t *php_http_curl_get_request_datasha /* request pool handler ops */ -static php_http_request_pool_t *php_http_curl_request_pool_init(php_http_request_pool_t *h, void *handle TSRMLS_DC) +static php_http_request_pool_t *php_http_curl_request_pool_init(php_http_request_pool_t *h, void *handle) { php_http_curl_request_pool_t *curl; + TSRMLS_FETCH_FROM_CTX(h->ts); if (!handle && !(handle = php_http_resource_factory_handle_ctor(h->rf TSRMLS_CC))) { php_http_error(HE_WARNING, PHP_HTTP_E_REQUEST_POOL, "could not initialize curl pool handle"); @@ -1345,7 +1349,7 @@ static void php_http_curl_request_pool_dtor(php_http_request_pool_t *h) curl->unfinished = 0; php_http_request_pool_reset(h); - php_http_resource_factory_handle_dtor(h->rf, curl->handle); + php_http_resource_factory_handle_dtor(h->rf, curl->handle TSRMLS_CC); efree(curl); h->ctx = NULL; @@ -1356,6 +1360,7 @@ static STATUS php_http_curl_request_pool_attach(php_http_request_pool_t *h, php_ php_http_curl_request_pool_t *curl = h->ctx; php_http_curl_request_t *recurl = r->ctx; CURLMcode rs; + TSRMLS_FETCH_FROM_CTX(h->ts); if (SUCCESS != php_http_curl_request_prepare(r, m, url, body)) { return FAILURE; @@ -1375,6 +1380,7 @@ static STATUS php_http_curl_request_pool_detach(php_http_request_pool_t *h, php_ php_http_curl_request_pool_t *curl = h->ctx; php_http_curl_request_t *recurl = r->ctx; CURLMcode rs = curl_multi_remove_handle(curl->handle, recurl->handle); + TSRMLS_FETCH_FROM_CTX(h->ts); if (CURLM_OK == rs) { return SUCCESS; @@ -1399,7 +1405,7 @@ static STATUS php_http_curl_request_pool_wait(php_http_request_pool_t *h, struct #ifdef PHP_HTTP_HAVE_EVENT if (curl->useevents) { - TSRMLS_FETCH_FROM_CTX(pool->ts); + TSRMLS_FETCH_FROM_CTX(h->ts); php_http_error(HE_WARNING, PHP_HTTP_E_RUNTIME, "not implemented"); return FAILURE; @@ -1461,6 +1467,8 @@ static void dolog(int i, const char *m) { #endif static STATUS php_http_curl_request_pool_exec(php_http_request_pool_t *h) { + TSRMLS_FETCH_FROM_CTX(h->ts); + #ifdef PHP_HTTP_HAVE_EVENT php_http_curl_request_pool_t *curl = h->ctx; @@ -1589,7 +1597,7 @@ static php_http_request_t *php_http_curl_request_init(php_http_request_t *h, voi curl_easy_setopt(handle, CURLOPT_DEBUGDATA, h); curl_easy_setopt(handle, CURLOPT_PROGRESSDATA, h); - php_http_curl_request_reset(h TSRMLS_CC); + php_http_curl_request_reset(h); return h; } @@ -1614,6 +1622,7 @@ static php_http_request_t *php_http_curl_request_copy(php_http_request_t *from, static void php_http_curl_request_dtor(php_http_request_t *h) { php_http_curl_request_t *ctx = h->ctx; + TSRMLS_FETCH_FROM_CTX(h->ts); curl_easy_setopt(ctx->handle, CURLOPT_NOPROGRESS, 1L); curl_easy_setopt(ctx->handle, CURLOPT_PROGRESSFUNCTION, NULL); @@ -1629,7 +1638,7 @@ static void php_http_curl_request_dtor(php_http_request_t *h) curl_slist_free_all(ctx->options.headers); ctx->options.headers = NULL; } - php_http_request_progress_dtor(&ctx->progress); + php_http_request_progress_dtor(&ctx->progress TSRMLS_CC); efree(ctx); h->ctx = NULL; @@ -1814,6 +1823,7 @@ retry: static STATUS php_http_curl_request_setopt(php_http_request_t *h, php_http_request_setopt_opt_t opt, void *arg) { php_http_curl_request_t *curl = h->ctx; + TSRMLS_FETCH_FROM_CTX(h->ts); switch (opt) { case PHP_HTTP_REQUEST_OPT_SETTINGS: diff --git a/php_http_encoding.c b/php_http_encoding.c index b7c994b..2580738 100644 --- a/php_http_encoding.c +++ b/php_http_encoding.c @@ -393,7 +393,6 @@ static php_http_encoding_stream_t *inflate_init(php_http_encoding_stream_t *s) static php_http_encoding_stream_t *dechunk_init(php_http_encoding_stream_t *s) { struct dechunk_ctx *ctx = pecalloc(1, sizeof(*ctx), (s->flags & PHP_HTTP_ENCODING_STREAM_PERSISTENT)); - TSRMLS_FETCH_FROM_CTX(s->ts); if (!php_http_buffer_init_ex(&ctx->buffer, PHP_HTTP_BUFFER_DEFAULT_SIZE, (s->flags & PHP_HTTP_ENCODING_STREAM_PERSISTENT) ? PHP_HTTP_BUFFER_INIT_PERSISTENT : 0)) { return NULL; @@ -942,7 +941,7 @@ void php_http_encoding_stream_object_free(void *object TSRMLS_DC) php_http_encoding_stream_object_t *o = (php_http_encoding_stream_object_t *) object; if (o->stream) { - php_http_encoding_stream_free(&o->stream TSRMLS_CC); + php_http_encoding_stream_free(&o->stream); } zend_object_std_dtor((zend_object *) o TSRMLS_CC); efree(o); @@ -994,7 +993,7 @@ PHP_METHOD(HttpEncodingStream, update) size_t encoded_len; char *encoded_str; - if (SUCCESS == php_http_encoding_stream_update(obj->stream, data_str, data_len, &encoded_str, &encoded_len TSRMLS_CC)) { + if (SUCCESS == php_http_encoding_stream_update(obj->stream, data_str, data_len, &encoded_str, &encoded_len)) { RETURN_STRINGL(encoded_str, encoded_len, 0); } } @@ -1011,7 +1010,7 @@ PHP_METHOD(HttpEncodingStream, flush) char *encoded_str; size_t encoded_len; - if (SUCCESS == php_http_encoding_stream_flush(obj->stream, &encoded_str, &encoded_len TSRMLS_CC)) { + if (SUCCESS == php_http_encoding_stream_flush(obj->stream, &encoded_str, &encoded_len)) { RETURN_STRINGL(encoded_str, encoded_len, 0); } } @@ -1040,7 +1039,7 @@ PHP_METHOD(HttpEncodingStream, finish) char *encoded_str; size_t encoded_len; - if (SUCCESS == php_http_encoding_stream_finish(obj->stream, &encoded_str, &encoded_len TSRMLS_CC)) { + if (SUCCESS == php_http_encoding_stream_finish(obj->stream, &encoded_str, &encoded_len)) { if (SUCCESS == php_http_encoding_stream_reset(&obj->stream)) { RETURN_STRINGL(encoded_str, encoded_len, 0); } else { diff --git a/php_http_env.c b/php_http_env.c index 511b878..1bd1a14 100644 --- a/php_http_env.c +++ b/php_http_env.c @@ -766,7 +766,7 @@ PHP_METHOD(HttpEnv, setResponseCode) #define PHP_HTTP_DO_NEGOTIATE(type, supported, rs_array) \ { \ HashTable *result; \ - if ((result = php_http_negotiate_ ##type(supported))) { \ + if ((result = php_http_negotiate_ ##type(supported TSRMLS_CC))) { \ PHP_HTTP_DO_NEGOTIATE_HANDLE_RESULT(result, supported, rs_array); \ } else { \ PHP_HTTP_DO_NEGOTIATE_HANDLE_DEFAULT(supported, rs_array); \ @@ -834,7 +834,7 @@ PHP_METHOD(HttpEnv, negotiate) array_init(rs_array); } - if ((rs = php_http_negotiate(value_str, supported, php_http_negotiate_default_func))) { + if ((rs = php_http_negotiate(value_str, supported, php_http_negotiate_default_func TSRMLS_CC))) { PHP_HTTP_DO_NEGOTIATE_HANDLE_RESULT(rs, supported, rs_array); } else { PHP_HTTP_DO_NEGOTIATE_HANDLE_DEFAULT(supported, rs_array); @@ -847,7 +847,7 @@ PHP_METHOD(HttpEnv, persistentHandlesStat) { if (SUCCESS == zend_parse_parameters_none()) { object_init(return_value); - if (php_http_persistent_handle_statall(HASH_OF(return_value))) { + if (php_http_persistent_handle_statall(HASH_OF(return_value) TSRMLS_CC)) { return; } zval_dtor(return_value); diff --git a/php_http_env_response.c b/php_http_env_response.c index 40fa941..2f14755 100644 --- a/php_http_env_response.c +++ b/php_http_env_response.c @@ -61,7 +61,7 @@ static void set_option(zval *options, const char *name_str, size_t name_len, int } } } -static zval *get_option(zval *options, const char *name_str, size_t name_len TSRMLS_CC) +static zval *get_option(zval *options, const char *name_str, size_t name_len TSRMLS_DC) { zval *val, **valptr; @@ -167,7 +167,7 @@ PHP_HTTP_API php_http_cache_status_t php_http_env_is_response_cached_by_last_mod zval_ptr_dtor(&zlm); } - ums = php_parse_date(header, NULL TSRMLS_CC); + ums = php_parse_date(header, NULL); efree(header); if (ums > 0 && ums <= lm) { @@ -180,7 +180,6 @@ PHP_HTTP_API php_http_cache_status_t php_http_env_is_response_cached_by_last_mod static size_t output(void *context, const char *buf, size_t len TSRMLS_DC) { php_http_env_response_t *r = context; - TSRMLS_FETCH_FROM_CTX(r->ts); PHPWRITE(buf, len); @@ -363,7 +362,7 @@ static STATUS php_http_env_response_send_head(php_http_env_response_t *r) ret = php_http_env_set_response_header_format(206, 1 TSRMLS_CC, "Content-Range: bytes %ld-%ld/%zu", Z_LVAL_PP(begin), Z_LVAL_PP(end), r->content.length); } } else { - php_http_boundary(r->range.boundary, sizeof(r->range.boundary)); + php_http_boundary(r->range.boundary, sizeof(r->range.boundary) TSRMLS_CC); ret = php_http_env_set_response_header_format(206, 1 TSRMLS_CC, "Content-Type: multipart/byteranges; boundary=%s", r->range.boundary); } } else { @@ -450,13 +449,13 @@ static STATUS php_http_env_response_send_head(php_http_env_response_t *r) zend_hash_internal_pointer_reset(result); if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(result, &key_str, &key_len, NULL, 0, NULL)) { if (!strcmp(key_str, "gzip")) { - if (!(r->content.encoder = php_http_encoding_stream_init(NULL, php_http_encoding_stream_get_deflate_ops(), PHP_HTTP_DEFLATE_TYPE_GZIP))) { + if (!(r->content.encoder = php_http_encoding_stream_init(NULL, php_http_encoding_stream_get_deflate_ops(), PHP_HTTP_DEFLATE_TYPE_GZIP TSRMLS_CC))) { ret = FAILURE; } else if (SUCCESS == (ret = php_http_env_set_response_header(0, ZEND_STRL("Content-Encoding: gzip"), 1 TSRMLS_CC))) { r->content.encoding = estrndup(key_str, key_len - 1); } } else if (!strcmp(key_str, "deflate")) { - if (!(r->content.encoder = php_http_encoding_stream_init(NULL, php_http_encoding_stream_get_deflate_ops(), PHP_HTTP_DEFLATE_TYPE_ZLIB))) { + if (!(r->content.encoder = php_http_encoding_stream_init(NULL, php_http_encoding_stream_get_deflate_ops(), PHP_HTTP_DEFLATE_TYPE_ZLIB TSRMLS_CC))) { ret = FAILURE; } else if (SUCCESS == (ret = php_http_env_set_response_header(0, ZEND_STRL("Content-Encoding: deflate"), 1 TSRMLS_CC))) { r->content.encoding = estrndup(key_str, key_len - 1); @@ -489,12 +488,12 @@ static STATUS php_http_env_response_send_head(php_http_env_response_t *r) return ret; } - switch (php_http_env_is_response_cached_by_etag(options, ZEND_STRL("If-None-Match"))) { + switch (php_http_env_is_response_cached_by_etag(options, ZEND_STRL("If-None-Match") TSRMLS_CC)) { case PHP_HTTP_CACHE_MISS: break; case PHP_HTTP_CACHE_NO: - if (PHP_HTTP_CACHE_HIT != php_http_env_is_response_cached_by_last_modified(options, ZEND_STRL("If-Modified-Since"))) { + if (PHP_HTTP_CACHE_HIT != php_http_env_is_response_cached_by_last_modified(options, ZEND_STRL("If-Modified-Since") TSRMLS_CC)) { break; } @@ -530,6 +529,7 @@ static STATUS php_http_env_response_send_body(php_http_env_response_t *r) { STATUS ret = SUCCESS; zval *zbody; + TSRMLS_FETCH_FROM_CTX(r->ts); if (r->done) { return ret; @@ -609,6 +609,7 @@ static STATUS php_http_env_response_send_body(php_http_env_response_t *r) PHP_HTTP_API STATUS php_http_env_response_send(php_http_env_response_t *r) { zval *zbody; + TSRMLS_FETCH_FROM_CTX(r->ts); /* check for ranges */ if ( (zbody = get_option(r->options, ZEND_STRL("body") TSRMLS_CC)) @@ -787,7 +788,7 @@ PHP_METHOD(HttpEnvResponse, setContentDisposition) if (file_len) { add_assoc_stringl_ex(arr, ZEND_STRS("filename"), file_str, file_len, 1); } - zend_update_property(Z_OBJCE_P(getThis()), getThis(), ZEND_STRL("contentDisposition"), arr); + zend_update_property(Z_OBJCE_P(getThis()), getThis(), ZEND_STRL("contentDisposition"), arr TSRMLS_CC); zval_ptr_dtor(&arr); } } @@ -850,7 +851,7 @@ PHP_METHOD(HttpEnvResponse, isCachedByEtag) char *header_name_str = NULL; int header_name_len = 0; - if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!", &header_name_str, &header_name_len)) { + if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!", &header_name_str, &header_name_len)) { if (!header_name_str || !header_name_len) { header_name_str = "If-None-Match"; header_name_len = lenof("If-None-Match"); diff --git a/php_http_env_response.h b/php_http_env_response.h index 67ae674..c6d5f05 100644 --- a/php_http_env_response.h +++ b/php_http_env_response.h @@ -32,7 +32,7 @@ typedef struct php_http_env_response { } php_http_env_response_t; PHP_HTTP_API php_http_env_response_t *php_http_env_response_init(php_http_env_response_t *r, zval *options TSRMLS_DC); -PHP_HTTP_API STATUS php_Http_env_response_send(php_http_env_response_t *r); +PHP_HTTP_API STATUS php_http_env_response_send(php_http_env_response_t *r); PHP_HTTP_API void php_http_env_response_dtor(php_http_env_response_t *r); PHP_HTTP_API void php_http_env_response_free(php_http_env_response_t **r); diff --git a/php_http_etag.c b/php_http_etag.c index b80cc9d..40757f7 100644 --- a/php_http_etag.c +++ b/php_http_etag.c @@ -8,10 +8,10 @@ #include #include -PHP_HTTP_API void *php_http_etag_init(TSRMLS_D) +PHP_HTTP_API php_http_etag_t *php_http_etag_init(const char *mode TSRMLS_DC) { - void *ctx = NULL; - char *mode = PHP_HTTP_G->env.etag_mode; + void *ctx; + php_http_etag_t *e; #ifdef PHP_HTTP_HAVE_HASH const php_hash_ops *eho = NULL; @@ -26,61 +26,69 @@ PHP_HTTP_API void *php_http_etag_init(TSRMLS_D) *((uint *) ctx) = ~0; } else if (mode && !strcasecmp(mode, "sha1")) { PHP_SHA1Init(ctx = emalloc(sizeof(PHP_SHA1_CTX))); - } else { + } else if (mode && !strcasecmp(mode, "md5")) { PHP_MD5Init(ctx = emalloc(sizeof(PHP_MD5_CTX))); + } else { + return NULL; } - return ctx; + e = emalloc(sizeof(*e)); + e->ctx = ctx; + e->mode = estrdup(mode); + TSRMLS_SET_CTX(e->ts); + + return e; } -PHP_HTTP_API char *php_http_etag_finish(void *ctx TSRMLS_DC) +PHP_HTTP_API char *php_http_etag_finish(php_http_etag_t *e) { unsigned char digest[128] = {0}; - char *etag = NULL, *mode = PHP_HTTP_G->env.etag_mode; + char *etag = NULL; #ifdef PHP_HTTP_HAVE_HASH const php_hash_ops *eho = NULL; - if (mode && (eho = php_hash_fetch_ops(mode, strlen(mode)))) { - eho->hash_final(digest, ctx); + if (mode && (eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) { + eho->hash_final(digest, e->ctx); etag = php_http_etag_digest(digest, eho->digest_size); } else #endif - if (mode && ((!strcasecmp(mode, "crc32")) || (!strcasecmp(mode, "crc32b")))) { - *((uint *) ctx) = ~*((uint *) ctx); - etag = php_http_etag_digest((const unsigned char *) ctx, sizeof(uint)); - } else if (mode && (!strcasecmp(mode, "sha1"))) { - PHP_SHA1Final(digest, ctx); + if (((!strcasecmp(e->mode, "crc32")) || (!strcasecmp(e->mode, "crc32b")))) { + *((uint *) e->ctx) = ~*((uint *) e->ctx); + etag = php_http_etag_digest((const unsigned char *) e->ctx, sizeof(uint)); + } else if ((!strcasecmp(e->mode, "sha1"))) { + PHP_SHA1Final(digest, e->ctx); etag = php_http_etag_digest(digest, 20); } else { - PHP_MD5Final(digest, ctx); + PHP_MD5Final(digest, e->ctx); etag = php_http_etag_digest(digest, 16); } - efree(ctx); + efree(e->ctx); + efree(e->mode); + efree(e); return etag; } -PHP_HTTP_API size_t php_http_etag_update(void *ctx, const char *data_ptr, size_t data_len TSRMLS_DC) +PHP_HTTP_API size_t php_http_etag_update(php_http_etag_t *e, const char *data_ptr, size_t data_len) { - char *mode = PHP_HTTP_G->env.etag_mode; #ifdef PHP_HTTP_HAVE_HASH const php_hash_ops *eho = NULL; - if (mode && (eho = php_hash_fetch_ops(mode, strlen(mode)))) { - eho->hash_update(ctx, (const unsigned char *) data_ptr, data_len); + if (mode && (eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) { + eho->hash_update(e->ctx, (const unsigned char *) data_ptr, data_len); } else #endif - if (mode && ((!strcasecmp(mode, "crc32")) || (!strcasecmp(mode, "crc32b")))) { - uint i, c = *((uint *) ctx); + if (((!strcasecmp(e->mode, "crc32")) || (!strcasecmp(e->mode, "crc32b")))) { + uint i, c = *((uint *) e->ctx); for (i = 0; i < data_len; ++i) { CRC32(c, data_ptr[i]); } - *((uint *)ctx) = c; - } else if (mode && (!strcasecmp(mode, "sha1"))) { - PHP_SHA1Update(ctx, (const unsigned char *) data_ptr, data_len); + *((uint *) e->ctx) = c; + } else if ((!strcasecmp(e->mode, "sha1"))) { + PHP_SHA1Update(e->ctx, (const unsigned char *) data_ptr, data_len); } else { - PHP_MD5Update(ctx, (const unsigned char *) data_ptr, data_len); + PHP_MD5Update(e->ctx, (const unsigned char *) data_ptr, data_len); } return data_len; diff --git a/php_http_etag.h b/php_http_etag.h index 25b1426..1ef7b23 100644 --- a/php_http_etag.h +++ b/php_http_etag.h @@ -1,9 +1,18 @@ #ifndef PHP_HTTP_ETAG_H #define PHP_HTTP_ETAG_H -PHP_HTTP_API void *php_http_etag_init(TSRMLS_D); -PHP_HTTP_API size_t php_http_etag_update(void *ctx, const char *data_ptr, size_t data_len TSRMLS_DC); -PHP_HTTP_API char *php_http_etag_finish(void *ctx TSRMLS_DC); +typedef struct php_http_etag { + void *ctx; + char *mode; + +#ifdef ZTS + void ***ts; +#endif +} php_http_etag_t; + +PHP_HTTP_API php_http_etag_t *php_http_etag_init(const char *mode TSRMLS_DC); +PHP_HTTP_API size_t php_http_etag_update(php_http_etag_t *e, const char *data_ptr, size_t data_len); +PHP_HTTP_API char *php_http_etag_finish(php_http_etag_t *e); static inline char *php_http_etag_digest(const unsigned char *digest, int len) { diff --git a/php_http_filter.c b/php_http_filter.c index 1a57399..9dd0827 100644 --- a/php_http_filter.c +++ b/php_http_filter.c @@ -297,7 +297,7 @@ static PHP_HTTP_FILTER_FUNCTION(zlib) } if (ptr->buflen) { - php_http_encoding_stream_update(buffer, ptr->buf, ptr->buflen, &encoded, &encoded_len TSRMLS_CC); + php_http_encoding_stream_update(buffer, ptr->buf, ptr->buflen, &encoded, &encoded_len); if (encoded) { if (encoded_len) { out_avail = 1; @@ -317,7 +317,7 @@ static PHP_HTTP_FILTER_FUNCTION(zlib) char *encoded = NULL; size_t encoded_len = 0; - php_http_encoding_stream_flush(buffer, &encoded, &encoded_len TSRMLS_CC); + php_http_encoding_stream_flush(buffer, &encoded, &encoded_len); if (encoded) { if (encoded_len) { out_avail = 1; @@ -331,7 +331,7 @@ static PHP_HTTP_FILTER_FUNCTION(zlib) char *encoded = NULL; size_t encoded_len = 0; - php_http_encoding_stream_finish(buffer, &encoded, &encoded_len TSRMLS_CC); + php_http_encoding_stream_finish(buffer, &encoded, &encoded_len); if (encoded) { if (encoded_len) { out_avail = 1; @@ -346,7 +346,7 @@ static PHP_HTTP_FILTER_FUNCTION(zlib) static PHP_HTTP_FILTER_DESTRUCTOR(zlib) { PHP_HTTP_FILTER_BUFFER(zlib) *buffer = (PHP_HTTP_FILTER_BUFFER(zlib) *) this->abstract; - php_http_encoding_stream_free(&buffer TSRMLS_CC); + php_http_encoding_stream_free(&buffer); } static PHP_HTTP_FILTER_OPS(deflate) = { @@ -387,7 +387,7 @@ static php_stream_filter *http_filter_create(const char *name, zval *params, int if ((b = php_http_encoding_stream_init(NULL, php_http_encoding_stream_get_inflate_ops(), flags TSRMLS_CC))) { if (!(f = php_stream_filter_alloc(&PHP_HTTP_FILTER_OP(inflate), b, p))) { - php_http_encoding_stream_free(&b TSRMLS_CC); + php_http_encoding_stream_free(&b); } } } else @@ -414,7 +414,7 @@ static php_stream_filter *http_filter_create(const char *name, zval *params, int } if ((b = php_http_encoding_stream_init(NULL, php_http_encoding_stream_get_deflate_ops(), flags TSRMLS_CC))) { if (!(f = php_stream_filter_alloc(&PHP_HTTP_FILTER_OP(deflate), b, p))) { - php_http_encoding_stream_free(&b TSRMLS_CC); + php_http_encoding_stream_free(&b); } } } diff --git a/php_http_header_parser.c b/php_http_header_parser.c index e6dca1e..c48e7c6 100644 --- a/php_http_header_parser.c +++ b/php_http_header_parser.c @@ -15,7 +15,7 @@ static const php_http_header_parser_state_spec_t php_http_header_parser_states[] }; -PHP_HTTP_API php_http_header_parser_t *php_http_header_parser_init(php_http_header_parser_t *parser TSRMLS_CC) +PHP_HTTP_API php_http_header_parser_t *php_http_header_parser_init(php_http_header_parser_t *parser TSRMLS_DC) { if (!parser) { parser = emalloc(sizeof(*parser)); diff --git a/php_http_message.c b/php_http_message.c index e6e28c1..318470e 100644 --- a/php_http_message.c +++ b/php_http_message.c @@ -24,7 +24,7 @@ PHP_HTTP_API zend_bool php_http_message_info_callback(php_http_message_t **messa /* advance message */ if (old->type || zend_hash_num_elements(&old->hdrs) || PHP_HTTP_BUFFER_LEN(old)) { - (*message) = php_http_message_init(NULL, 0); + (*message) = php_http_message_init(NULL, 0 TSRMLS_CC); (*message)->parent = old; (*headers) = &((*message)->hdrs); } @@ -60,7 +60,7 @@ PHP_HTTP_API php_http_message_t *php_http_message_init_env(php_http_message_t *m switch (type) { case PHP_HTTP_REQUEST: if ((sval = php_http_env_get_server_var(ZEND_STRL("SERVER_PROTOCOL"), 1 TSRMLS_CC)) && !strncmp(Z_STRVAL_P(sval), "HTTP/", lenof("HTTP/"))) { - php_http_version_parse(&message->http.version, Z_STRVAL_P(sval)); + php_http_version_parse(&message->http.version, Z_STRVAL_P(sval) TSRMLS_CC); } else { message->http.version.major = 1; message->http.version.minor = 1; @@ -76,7 +76,7 @@ PHP_HTTP_API php_http_message_t *php_http_message_init_env(php_http_message_t *m if ((mbody = php_http_env_get_request_body(TSRMLS_C))) { php_http_message_body_dtor(&message->body); - php_http_message_body_copy(mbody, &message->body, 0 TSRMLS_CC); + php_http_message_body_copy(mbody, &message->body, 0); } break; @@ -99,7 +99,7 @@ PHP_HTTP_API php_http_message_t *php_http_message_init_env(php_http_message_t *m php_http_env_get_response_headers(&message->hdrs TSRMLS_CC); - if (php_output_get_level()) { + if (php_output_get_level(TSRMLS_C)) { if (php_output_get_status(TSRMLS_C) & PHP_OUTPUT_SENT) { php_http_error(HE_WARNING, PHP_HTTP_E_RUNTIME, "Could not fetch response body, output has already been sent at %s:%d", php_output_get_start_filename(TSRMLS_C), php_output_get_start_lineno(TSRMLS_C)); goto error; @@ -154,6 +154,7 @@ PHP_HTTP_API zval *php_http_message_header(php_http_message_t *msg, char *key_st zval *header_str, **val; HashPosition pos; php_http_buffer_t str; + TSRMLS_FETCH_FROM_CTX(msg->ts); php_http_buffer_init(&str); MAKE_STD_ZVAL(header_str); @@ -227,6 +228,7 @@ static inline void message_headers(php_http_message_t *msg, php_http_buffer_t *s HashPosition pos1; zval **header, *h; size_t size; + TSRMLS_FETCH_FROM_CTX(msg->ts); switch (msg->type) { case PHP_HTTP_REQUEST: @@ -317,7 +319,6 @@ static inline void message_headers(php_http_message_t *msg, php_http_buffer_t *s PHP_HTTP_API void php_http_message_to_callback(php_http_message_t *msg, php_http_pass_callback_t cb, void *cb_arg) { php_http_buffer_t str; - TSRMLS_FETCH_FROM_CTX(msg->ts); php_http_buffer_init_ex(&str, 0x1000, 0); message_headers(msg, &str); @@ -325,9 +326,9 @@ PHP_HTTP_API void php_http_message_to_callback(php_http_message_t *msg, php_http php_http_buffer_dtor(&str); if (php_http_message_body_size(&msg->body)) { - cb(cb_arg, ZEND_STRL(PHP_HTTP_CRLF) TSRMLS_CC); + cb(cb_arg, ZEND_STRL(PHP_HTTP_CRLF)); php_http_message_body_to_callback(&msg->body, cb, cb_arg, 0, 0); - cb(cb_arg, ZEND_STRL(PHP_HTTP_CRLF) TSRMLS_CC); + cb(cb_arg, ZEND_STRL(PHP_HTTP_CRLF)); } } @@ -425,11 +426,12 @@ PHP_HTTP_API php_http_message_t *php_http_message_interconnect(php_http_message_ return m1; } -PHP_HTTP_API void php_http_message_to_struct(php_http_message_t *msg, zval *obj TSRMLS_DC) +PHP_HTTP_API void php_http_message_to_struct(php_http_message_t *msg, zval *obj) { zval strct; zval *headers; char *version; + TSRMLS_FETCH_FROM_CTX(msg->ts); INIT_PZVAL_ARRAY(&strct, HASH_OF(obj)); @@ -574,7 +576,7 @@ PHP_HTTP_API php_http_message_t *php_http_message_copy(php_http_message_t *from, info.type = from->type; info.http = from->http; - copy = temp = php_http_message_init(to, 0); + copy = temp = php_http_message_init(to, 0 TSRMLS_CC); php_http_message_set_info(temp, &info); zend_hash_copy(&temp->hdrs, &from->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); php_http_message_body_copy(&from->body, &temp->body, 1); @@ -583,7 +585,7 @@ PHP_HTTP_API php_http_message_t *php_http_message_copy(php_http_message_t *from, info.type = from->parent->type; info.http = from->parent->http; - temp->parent = php_http_message_init(NULL, 0); + temp->parent = php_http_message_init(NULL, 0 TSRMLS_CC); php_http_message_set_info(temp->parent, &info); zend_hash_copy(&temp->parent->hdrs, &from->parent->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); php_http_message_body_copy(&from->body, &temp->body, 1); @@ -1105,7 +1107,7 @@ zend_object_value php_http_message_object_clone(zval *this_ptr TSRMLS_DC) php_http_message_object_t *new_obj = NULL; php_http_message_object_t *old_obj = zend_object_store_get_object(this_ptr TSRMLS_CC); - new_ov = php_http_message_object_new_ex(old_obj->zo.ce, php_http_message_copy(old_obj->message, NULL), &new_obj); + new_ov = php_http_message_object_new_ex(old_obj->zo.ce, php_http_message_copy(old_obj->message, NULL), &new_obj TSRMLS_CC); zend_objects_clone_members(&new_obj->zo, new_ov, &old_obj->zo, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC); return new_ov; @@ -1288,7 +1290,7 @@ PHP_METHOD(HttpMessage, __construct) php_http_message_dtor(msg); with_error_handling(EH_THROW, php_http_exception_class_entry) { - if ((obj->message = php_http_message_parse(msg, message, length))) { + if ((obj->message = php_http_message_parse(msg, message, length TSRMLS_CC))) { if (obj->message->parent) { obj->parent = php_http_message_object_new_ex(Z_OBJCE_P(getThis()), obj->message->parent, NULL TSRMLS_CC); } diff --git a/php_http_message_body.c b/php_http_message_body.c index f80cb46..ad92a17 100644 --- a/php_http_message_body.c +++ b/php_http_message_body.c @@ -79,6 +79,7 @@ PHP_HTTP_API php_http_message_body_t *php_http_message_body_copy(php_http_messag PHP_HTTP_API void php_http_message_body_dtor(php_http_message_body_t *body) { + TSRMLS_FETCH_FROM_CTX(body->ts); /* NO FIXME: shows leakinfo in DEBUG mode */ zend_list_delete(body->stream_id); STR_FREE(body->boundary); @@ -115,7 +116,7 @@ PHP_HTTP_API const char *php_http_message_body_boundary(php_http_message_body_t PHP_HTTP_API char *php_http_message_body_etag(php_http_message_body_t *body) { TSRMLS_FETCH_FROM_CTX(body->ts); - php_stream_statbuf *ssb = php_http_message_body_stat(body); + const php_stream_statbuf *ssb = php_http_message_body_stat(body); /* real file or temp buffer ? */ if (body->ssb.sb.st_mtime) { @@ -124,10 +125,10 @@ PHP_HTTP_API char *php_http_message_body_etag(php_http_message_body_t *body) spprintf(&etag, 0, "%lx-%lx-%lx", ssb->sb.st_ino, ssb->sb.st_mtime, ssb->sb.st_size); return etag; } else { - void *ctx = php_http_etag_init(TSRMLS_C); + php_http_etag_t *etag = php_http_etag_init(PHP_HTTP_G->env.etag_mode TSRMLS_CC); - php_http_message_body_to_callback(body, php_http_etag_update, ctx, 0, 0); - return php_http_etag_finish(ctx TSRMLS_CC); + php_http_message_body_to_callback(body, (php_http_pass_callback_t) php_http_etag_update, etag, 0, 0); + return php_http_etag_finish(etag); } } @@ -213,7 +214,6 @@ PHP_HTTP_API size_t php_http_message_body_appendf(php_http_message_body_t *body, PHP_HTTP_API STATUS php_http_message_body_add(php_http_message_body_t *body, HashTable *fields, HashTable *files) { zval tmp; - TSRMLS_FETCH_FROM_CTX(body->ts); if (fields) { INIT_PZVAL_ARRAY(&tmp, fields); @@ -234,7 +234,10 @@ PHP_HTTP_API STATUS php_http_message_body_add(php_http_message_body_t *body, Has PHP_HTTP_API STATUS php_http_message_body_add_field(php_http_message_body_t *body, const char *name, const char *value_str, size_t value_len) { - char *safe_name = php_addslashes(estrdup(name), strlen(name), NULL, 1 TSRMLS_CC); + char *safe_name; + TSRMLS_FETCH_FROM_CTX(body->ts); + + safe_name = php_addslashes(estrdup(name), strlen(name), NULL, 1 TSRMLS_CC); BOUNDARY_OPEN(body); php_http_message_body_appendf( @@ -313,6 +316,7 @@ static STATUS add_recursive_fields(php_http_message_body_t *body, const char *na zval **val; HashPosition pos; php_http_array_hashkey_t key = php_http_array_hashkey_init(0); + TSRMLS_FETCH_FROM_CTX(body->ts); if (!HASH_OF(value)->nApplyCount) { ++HASH_OF(value)->nApplyCount; @@ -340,6 +344,7 @@ static STATUS add_recursive_files(php_http_message_body_t *body, const char *nam { if (Z_TYPE_P(value) == IS_ARRAY || Z_TYPE_P(value) == IS_OBJECT) { zval **zfile, **zname, **ztype; + TSRMLS_FETCH_FROM_CTX(body->ts); if ((SUCCESS == zend_hash_find(HASH_OF(value), ZEND_STRS("name"), (void *) &zname)) && (SUCCESS == zend_hash_find(HASH_OF(value), ZEND_STRS("file"), (void *) &zfile)) @@ -377,6 +382,7 @@ static STATUS add_recursive_files(php_http_message_body_t *body, const char *nam } } } else { + TSRMLS_FETCH_FROM_CTX(body->ts); php_http_error(HE_WARNING, PHP_HTTP_E_MESSAGE_BODY, "Unrecognized array format for message body file to add"); return FAILURE; } @@ -471,7 +477,7 @@ zend_object_value php_http_message_body_object_clone(zval *object TSRMLS_DC) php_http_message_body_object_t *new_obj = NULL; php_http_message_body_object_t *old_obj = zend_object_store_get_object(object TSRMLS_CC); - new_ov = php_http_message_body_object_new_ex(old_obj->zo.ce, php_http_message_body_copy(old_obj->body, NULL, 1), &new_obj); + new_ov = php_http_message_body_object_new_ex(old_obj->zo.ce, php_http_message_body_copy(old_obj->body, NULL, 1), &new_obj TSRMLS_CC); zend_objects_clone_members(&new_obj->zo, new_ov, &old_obj->zo, Z_OBJ_HANDLE_P(object) TSRMLS_CC); return new_ov; @@ -547,12 +553,16 @@ struct fcd { zval *fcz; zend_fcall_info *fci; zend_fcall_info_cache *fcc; +#ifdef ZTS + void ***ts; +#endif }; -static size_t pass(void *cb_arg, const char *str, size_t len TSRMLS_DC) +static size_t pass(void *cb_arg, const char *str, size_t len) { struct fcd *fcd = cb_arg; zval *zdata; + TSRMLS_FETCH_FROM_CTX(fcd->ts); MAKE_STD_ZVAL(zdata); ZVAL_STRINGL(zdata, str, len, 1); diff --git a/php_http_message_body.h b/php_http_message_body.h index 4a621a4..e0ff8d9 100644 --- a/php_http_message_body.h +++ b/php_http_message_body.h @@ -25,7 +25,7 @@ typedef struct php_http_message_body { } php_http_message_body_t; PHP_HTTP_API php_http_message_body_t *php_http_message_body_init(php_http_message_body_t *body, php_stream *stream TSRMLS_DC); -PHP_HTTP_API php_http_message_body_t *php_http_message_body_copy(php_http_message_body_t *from, php_http_message_body_t *to, zend_bool dup_internal_stream_and_contents TSRMLS_DC); +PHP_HTTP_API php_http_message_body_t *php_http_message_body_copy(php_http_message_body_t *from, php_http_message_body_t *to, zend_bool dup_internal_stream_and_contents); PHP_HTTP_API STATUS php_http_message_body_add(php_http_message_body_t *body, HashTable *fields, HashTable *files); PHP_HTTP_API STATUS php_http_message_body_add_field(php_http_message_body_t *body, const char *name, const char *value_str, size_t value_len); PHP_HTTP_API STATUS php_http_message_body_add_file(php_http_message_body_t *body, const char *name, const char *path, const char *ctype); diff --git a/php_http_message_parser.c b/php_http_message_parser.c index 9accc35..fce24ed 100644 --- a/php_http_message_parser.c +++ b/php_http_message_parser.c @@ -74,10 +74,10 @@ PHP_HTTP_API void php_http_message_parser_dtor(php_http_message_parser_t *parser php_http_header_parser_dtor(&parser->header); zend_stack_destroy(&parser->stack); if (parser->dechunk) { - php_http_encoding_stream_free(&parser->dechunk TSRMLS_CC); + php_http_encoding_stream_free(&parser->dechunk); } if (parser->inflate) { - php_http_encoding_stream_free(&parser->inflate TSRMLS_CC); + php_http_encoding_stream_free(&parser->inflate); } } @@ -277,7 +277,7 @@ PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_parse(php_h char *dec_str = NULL; size_t dec_len; - if (SUCCESS != php_http_encoding_stream_update(parser->inflate, str, len, &dec_str, &dec_len TSRMLS_CC)) { + if (SUCCESS != php_http_encoding_stream_update(parser->inflate, str, len, &dec_str, &dec_len)) { return php_http_message_parser_state_push(parser, 1, PHP_HTTP_MESSAGE_PARSER_STATE_FAILURE); } @@ -345,7 +345,7 @@ PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_parse(php_h char *dec_str = NULL; size_t dec_len; - if (SUCCESS != php_http_encoding_stream_update(parser->dechunk, buffer->data, buffer->used, &dec_str, &dec_len TSRMLS_CC)) { + if (SUCCESS != php_http_encoding_stream_update(parser->dechunk, buffer->data, buffer->used, &dec_str, &dec_len)) { return FAILURE; } @@ -370,7 +370,7 @@ PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_parse(php_h char *dec_str = NULL; size_t dec_len; - if (SUCCESS != php_http_encoding_stream_finish(parser->dechunk, &dec_str, &dec_len TSRMLS_CC)) { + if (SUCCESS != php_http_encoding_stream_finish(parser->dechunk, &dec_str, &dec_len)) { return php_http_message_parser_state_push(parser, 1, PHP_HTTP_MESSAGE_PARSER_STATE_FAILURE); } php_http_encoding_stream_dtor(parser->dechunk); diff --git a/php_http_misc.c b/php_http_misc.c index 8caa319..377aa9a 100644 --- a/php_http_misc.c +++ b/php_http_misc.c @@ -195,7 +195,7 @@ static inline int scope_error_handling(long type TSRMLS_DC) return EH_THROW; } - if (EG(This) && instanceof_function(Z_OBJCE_P(EG(This)), php_http_object_class_entry)) { + if (EG(This) && instanceof_function(Z_OBJCE_P(EG(This)), php_http_object_class_entry TSRMLS_CC)) { return php_http_object_get_error_handling(EG(This) TSRMLS_CC); } @@ -212,7 +212,7 @@ void php_http_error(long type TSRMLS_DC, long code, const char *format, ...) char *message; zend_class_entry *ce = php_http_exception_class_entry; - if (0&& EG(exception_class) && instanceof_function(EG(exception_class), php_http_exception_class_entry)) { + if (0&& EG(exception_class) && instanceof_function(EG(exception_class), php_http_exception_class_entry TSRMLS_CC)) { ce = EG(exception_class); } diff --git a/php_http_neon.c b/php_http_neon.c index f0bc293..99f7cf5 100644 --- a/php_http_neon.c +++ b/php_http_neon.c @@ -215,6 +215,7 @@ static STATUS set_options(php_http_request_t *h, HashTable *options) zval *zoption; int range_req = 0; php_http_neon_request_t *neon = h->ctx; + TSRMLS_FETCH_FROM_CTX(h->ts); /* proxy */ if ((zoption = get_option(&neon->options.cache, options, ZEND_STRS("proxyhost"), IS_STRING))) { @@ -353,7 +354,8 @@ static STATUS set_options(php_http_request_t *h, HashTable *options) if (PHP_HTTP_BUFFER_LEN(&rs)) { /* ignore last comma */ - php_http_buffer_appendf(&neon->options.headers, "Range: bytes=%.*s" PHP_HTTP_CRLF, rs.used - 1, rs.data); + int used = rs.used > INT_MAX ? INT_MAX : rs.used; + php_http_buffer_appendf(&neon->options.headers, "Range: bytes=%.*s" PHP_HTTP_CRLF, used - 1, rs.data); range_req = 1; } php_http_buffer_dtor(&rs); @@ -536,12 +538,13 @@ static php_http_request_t *php_http_neon_request_copy(php_http_request_t *from, static void php_http_neon_request_dtor(php_http_request_t *h) { php_http_neon_request_t *ctx = h->ctx; + TSRMLS_FETCH_FROM_CTX(h->ts); php_http_neon_request_reset(h); php_http_buffer_dtor(&ctx->options.headers); zend_hash_destroy(&ctx->options.cache); - php_http_request_progress_dtor(&ctx->progress); + php_http_request_progress_dtor(&ctx->progress TSRMLS_CC); efree(ctx); h->ctx = NULL; @@ -550,6 +553,7 @@ static void php_http_neon_request_dtor(php_http_request_t *h) static STATUS php_http_neon_request_reset(php_http_request_t *h) { php_http_neon_request_t *neon = h->ctx; + TSRMLS_FETCH_FROM_CTX(h->ts); php_http_buffer_reset(&neon->options.headers); STR_SET(neon->options.useragent, NULL); @@ -585,7 +589,7 @@ static STATUS php_http_neon_request_reset(php_http_request_t *h) neon->options.timeout.read = 0; neon->options.timeout.connect = 0; - php_http_request_progress_dtor(&neon->progress); + php_http_request_progress_dtor(&neon->progress TSRMLS_CC); return SUCCESS; } @@ -602,7 +606,7 @@ static STATUS php_http_neon_request_exec(php_http_request_t *h, php_http_request php_http_neon_request_t *neon = h->ctx; TSRMLS_FETCH_FROM_CTX(h->ts); - if (!(meth = php_http_request_method_name(meth_id))) { + if (!(meth = php_http_request_method_name(meth_id TSRMLS_CC))) { php_http_error(HE_WARNING, PHP_HTTP_E_REQUEST_METHOD, "Unsupported request method: %d (%s)", meth, url); return FAILURE; } @@ -757,6 +761,7 @@ retry: static STATUS php_http_neon_request_setopt(php_http_request_t *h, php_http_request_setopt_opt_t opt, void *arg) { php_http_neon_request_t *neon = h->ctx; + TSRMLS_FETCH_FROM_CTX(h->ts); switch (opt) { case PHP_HTTP_REQUEST_OPT_SETTINGS: diff --git a/php_http_params.c b/php_http_params.c index 2cc9a09..b056048 100644 --- a/php_http_params.c +++ b/php_http_params.c @@ -16,7 +16,6 @@ PHP_HTTP_API void php_http_params_parse_default_func(void *arg, const char *key, int keylen, const char *val, int vallen TSRMLS_DC) { - char *kdup; zval tmp, *entry; HashTable *ht = (HashTable *) arg; @@ -27,15 +26,13 @@ PHP_HTTP_API void php_http_params_parse_default_func(void *arg, const char *key, MAKE_STD_ZVAL(entry); array_init(entry); if (keylen) { - kdup = estrndup(key, keylen); - add_assoc_stringl_ex(entry, kdup, keylen + 1, (char *) val, vallen, 1); - efree(kdup); + add_assoc_stringl_ex(entry, key, keylen + 1, estrndup(val, vallen), vallen, 0); } else { - add_next_index_stringl(entry, (char *) val, vallen, 1); + add_next_index_stringl(entry, val, vallen, 1); } add_next_index_zval(&tmp, entry); } else { - add_next_index_stringl(&tmp, (char *) key, keylen, 1); + add_next_index_stringl(&tmp, key, keylen, 1); } } } diff --git a/php_http_persistent_handle.c b/php_http_persistent_handle.c index 55d53d0..720e8e6 100644 --- a/php_http_persistent_handle.c +++ b/php_http_persistent_handle.c @@ -182,6 +182,7 @@ static void php_http_persistent_handles_hash_dtor(void *p) php_http_persistent_handle_provider_t *provider = (php_http_persistent_handle_provider_t *) p; php_http_persistent_handle_list_t **list, *list_tmp; HashPosition pos; + TSRMLS_FETCH(); FOREACH_HASH_VAL(pos, &provider->list.free, list) { /* fix shutdown crash in PHP4 */ @@ -304,7 +305,7 @@ PHP_HTTP_API void *php_http_persistent_handle_accrete(php_http_persistent_handle PHP_HTTP_API void php_http_persistent_handle_release(php_http_persistent_handle_factory_t *a, void *handle TSRMLS_DC) { LOCK(); - php_http_persistent_handle_do_release(a->provider, a->ident.str, a->ident.len, &handle); + php_http_persistent_handle_do_release(a->provider, a->ident.str, a->ident.len, &handle TSRMLS_CC); UNLOCK(); } diff --git a/php_http_request.c b/php_http_request.c index 6b8d444..61b9395 100644 --- a/php_http_request.c +++ b/php_http_request.c @@ -29,8 +29,8 @@ PHP_HTTP_API php_http_request_t *php_http_request_init(php_http_request_t *h, ph memset(h, 0, sizeof(*h)); h->ops = ops; - h->rf = rf ? rf : php_http_resource_factory_init(NULL, h->ops->rsrc, NULL, NULL TSRMLS_CC); - h->buffer = php_http_buffer_init(NULL TSRMLS_CC); + h->rf = rf ? rf : php_http_resource_factory_init(NULL, h->ops->rsrc, NULL, NULL); + h->buffer = php_http_buffer_init(NULL); h->parser = php_http_message_parser_init(NULL TSRMLS_CC); h->message = php_http_message_init(NULL, 0 TSRMLS_CC); @@ -539,7 +539,7 @@ STATUS php_http_request_object_responsehandler(php_http_request_object_t *obj, z return ret; } -static int apply_pretty_key(void *pDest, int num_args, va_list args, zend_hash_key *hash_key) +static int apply_pretty_key(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { if (hash_key->arKey && hash_key->nKeyLength > 1) { hash_key->h = zend_hash_func(php_http_pretty_key(hash_key->arKey, hash_key->nKeyLength - 1, 1, 0), hash_key->nKeyLength); diff --git a/php_http_request_datashare.c b/php_http_request_datashare.c index f44d5b0..dec1ffa 100644 --- a/php_http_request_datashare.c +++ b/php_http_request_datashare.c @@ -1,6 +1,7 @@ #include "php_http.h" +#include #include #include @@ -55,7 +56,7 @@ PHP_HTTP_API php_http_request_datashare_t *php_http_request_datashare_init(php_h TSRMLS_SET_CTX(h->ts); } h->ops = ops; - h->rf = rf ? rf : php_http_resource_factory_init(NULL, h->ops->rsrc, NULL, NULL TSRMLS_CC); + h->rf = rf ? rf : php_http_resource_factory_init(NULL, h->ops->rsrc, NULL, NULL); if (h->ops->init) { if (!(h = h->ops->init(h, init_arg))) { @@ -152,11 +153,11 @@ static void detach(void *r, void *h TSRMLS_DC) PHP_HTTP_API void php_http_request_datashare_reset(php_http_request_datashare_t *h) { + TSRMLS_FETCH_FROM_CTX(h->ts); + if (h->ops->reset) { h->ops->reset(h); } else if (h->ops->detach) { - TSRMLS_FETCH_FROM_CTX(h->ts); - zend_llist_apply_with_argument(PHP_HTTP_REQUEST_DATASHARE_REQUESTS(h), detach, h TSRMLS_CC); } @@ -237,7 +238,7 @@ void php_http_request_datashare_object_free(void *object TSRMLS_DC) if (!o->share->persistent) { php_http_request_datashare_free(&o->share); } - zend_object_std_dtor((zend_object *) o); + zend_object_std_dtor((zend_object *) o TSRMLS_CC); efree(o); } diff --git a/php_http_request_factory.c b/php_http_request_factory.c index be5cb7d..1e61e59 100644 --- a/php_http_request_factory.c +++ b/php_http_request_factory.c @@ -89,7 +89,7 @@ PHP_METHOD(HttpRequestFactory, __construct) FOREACH_HASH_KEYVAL(pos, options, key, val) { if (key.type == HASH_KEY_IS_STRING) { zval *newval = php_http_zsep(1, Z_TYPE_PP(val), *val); - zend_update_property(php_http_request_factory_class_entry, getThis(), key.str, key.len - 1, newval); + zend_update_property(php_http_request_factory_class_entry, getThis(), key.str, key.len - 1, newval TSRMLS_CC); zval_ptr_dtor(&newval); } } @@ -140,7 +140,7 @@ PHP_METHOD(HttpRequestFactory, createRequest) (php_http_resource_factory_handle_dtor_t) php_http_persistent_handle_release }; - rf = php_http_resource_factory_init(NULL, &ops, pf, (void (*)(void *)) php_http_persistent_handle_abandon TSRMLS_CC); + rf = php_http_resource_factory_init(NULL, &ops, pf, (void (*)(void *)) php_http_persistent_handle_abandon); } efree(name_str); @@ -217,7 +217,7 @@ PHP_METHOD(HttpRequestFactory, createPool) (php_http_resource_factory_handle_dtor_t) php_http_persistent_handle_release }; - rf = php_http_resource_factory_init(NULL, &ops, pf, (void (*)(void *)) php_http_persistent_handle_abandon TSRMLS_CC); + rf = php_http_resource_factory_init(NULL, &ops, pf, (void (*)(void *)) php_http_persistent_handle_abandon); } efree(name_str); @@ -284,7 +284,7 @@ PHP_METHOD(HttpRequestFactory, createDataShare) (php_http_resource_factory_handle_dtor_t) php_http_persistent_handle_release }; - rf = php_http_resource_factory_init(NULL, &ops, pf, (void (*)(void *)) php_http_persistent_handle_abandon TSRMLS_CC); + rf = php_http_resource_factory_init(NULL, &ops, pf, (void (*)(void *)) php_http_persistent_handle_abandon); } efree(name_str); diff --git a/php_http_request_method.c b/php_http_request_method.c index d159ad8..3ca0b55 100644 --- a/php_http_request_method.c +++ b/php_http_request_method.c @@ -52,7 +52,7 @@ static PHP_HTTP_STRLIST(php_http_request_methods) = PHP_HTTP_STRLIST_STOP ; -PHP_HTTP_API const char *php_http_request_method_name(php_http_request_method_t meth) +PHP_HTTP_API const char *php_http_request_method_name(php_http_request_method_t meth TSRMLS_DC) { if (meth > PHP_HTTP_NO_REQUEST_METHOD && meth < PHP_HTTP_MAX_REQUEST_METHOD) { return php_http_strlist_find(php_http_request_methods, 0, meth); diff --git a/php_http_request_method.h b/php_http_request_method.h index 6c29e80..bb2efc7 100644 --- a/php_http_request_method.h +++ b/php_http_request_method.h @@ -53,7 +53,7 @@ typedef enum php_http_request_method { PHP_HTTP_MAX_REQUEST_METHOD = 28 } php_http_request_method_t; -PHP_HTTP_API const char *php_http_request_method_name(php_http_request_method_t meth); +PHP_HTTP_API const char *php_http_request_method_name(php_http_request_method_t meth TSRMLS_DC); PHP_HTTP_API STATUS php_http_request_method_register(const char *meth_str, size_t meth_len, long *id TSRMLS_DC); extern zend_class_entry *php_http_request_method_class_entry; diff --git a/php_http_request_pool.c b/php_http_request_pool.c index 379e3b1..96a3a1a 100644 --- a/php_http_request_pool.c +++ b/php_http_request_pool.c @@ -14,7 +14,7 @@ PHP_HTTP_API php_http_request_pool_t *php_http_request_pool_init(php_http_reques memset(h, 0, sizeof(*h)); h->ops = ops; - h->rf = rf ? rf : php_http_resource_factory_init(NULL, h->ops->rsrc, NULL, NULL TSRMLS_CC); + h->rf = rf ? rf : php_http_resource_factory_init(NULL, h->ops->rsrc, NULL, NULL); zend_llist_init(&h->requests.attached, sizeof(zval *), (llist_dtor_func_t) ZVAL_PTR_DTOR, 0); zend_llist_init(&h->requests.finished, sizeof(zval *), (llist_dtor_func_t) ZVAL_PTR_DTOR, 0); TSRMLS_SET_CTX(h->ts); @@ -72,7 +72,7 @@ PHP_HTTP_API STATUS php_http_request_pool_attach(php_http_request_pool_t *h, zva php_http_message_body_t *body = NULL; php_http_request_object_t *obj = zend_object_store_get_object(request TSRMLS_CC); - if (SUCCESS != php_http_request_object_requesthandler(obj, request, &m, &url, &body)) { + if (SUCCESS != php_http_request_object_requesthandler(obj, request, &m, &url, &body TSRMLS_CC)) { return FAILURE; } if (SUCCESS == h->ops->attach(h, obj->request, m, url, body)) { @@ -130,8 +130,6 @@ PHP_HTTP_API int php_http_request_pool_once(php_http_request_pool_t *h) PHP_HTTP_API STATUS php_http_request_pool_exec(php_http_request_pool_t *h) { - TSRMLS_FETCH_FROM_CTX(h->ts); - if (h->ops->exec) { return h->ops->exec(h); } diff --git a/php_http_url.c b/php_http_url.c index 0bfd657..79966b6 100644 --- a/php_http_url.c +++ b/php_http_url.c @@ -340,7 +340,7 @@ PHP_HTTP_API STATUS php_http_url_encode_hash(HashTable *hash, zend_bool override php_http_buffer_append(qstr, pre_encoded_data, pre_encoded_len); } - if (SUCCESS != php_http_url_encode_hash_recursive(hash, qstr, arg_sep, arg_sep_len, NULL, 0)) { + if (SUCCESS != php_http_url_encode_hash_recursive(hash, qstr, arg_sep, arg_sep_len, NULL, 0 TSRMLS_CC)) { php_http_buffer_free(&qstr); return FAILURE; } -- 2.30.2