Skip to content

Commit adf22b6

Browse files
committed
PHP: fixed compatibility with ZTS.
This closes #184 issue on GitHub.
1 parent 39cd4a9 commit adf22b6

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

auto/modules/php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ if /bin/sh -c "${NXT_PHP_CONFIG} --version" >> $NXT_AUTOCONF_ERR 2>&1; then
111111
#include <php_main.h>
112112

113113
int main() {
114-
php_request_startup();
114+
php_module_startup(NULL, NULL, 0);
115115
return 0;
116116
}"
117117

src/nxt_php_sapi.c

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@ static void nxt_php_set_options(nxt_task_t *task, nxt_conf_value_t *options,
4545
int type);
4646
static nxt_int_t nxt_php_alter_option(nxt_str_t *name, nxt_str_t *value,
4747
int type);
48-
static int nxt_php_send_headers(sapi_headers_struct *sapi_headers);
49-
static char *nxt_php_read_cookies(void);
48+
static int nxt_php_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC);
49+
static char *nxt_php_read_cookies(TSRMLS_D);
5050
static void nxt_php_set_sptr(nxt_unit_request_info_t *req, const char *name,
5151
nxt_unit_sptr_t *v, uint32_t len, zval *track_vars_array TSRMLS_DC);
5252
nxt_inline void nxt_php_set_str(nxt_unit_request_info_t *req, const char *name,
5353
nxt_str_t *s, zval *track_vars_array TSRMLS_DC);
5454
static void nxt_php_set_cstr(nxt_unit_request_info_t *req, const char *name,
5555
char *str, uint32_t len, zval *track_vars_array TSRMLS_DC);
56-
static void nxt_php_register_variables(zval *track_vars_array);
56+
static void nxt_php_register_variables(zval *track_vars_array TSRMLS_DC);
5757
#ifdef NXT_HAVE_PHP_LOG_MESSAGE_WITH_SYSLOG_TYPE
5858
static void nxt_php_log_message(char *message, int syslog_type_int);
5959
#else
60-
static void nxt_php_log_message(char *message);
60+
static void nxt_php_log_message(char *message TSRMLS_DC);
6161
#endif
6262

6363
#ifdef NXT_PHP7
@@ -159,6 +159,9 @@ NXT_EXPORT nxt_app_module_t nxt_app_module = {
159159

160160

161161
static nxt_task_t *nxt_php_task;
162+
#ifdef ZTS
163+
static void ***tsrm_ls;
164+
#endif
162165

163166

164167
static nxt_int_t
@@ -262,6 +265,17 @@ nxt_php_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
262265
nxt_memcpy(index->start, c->index.start, c->index.length);
263266
}
264267

268+
#ifdef ZTS
269+
tsrm_startup(1, 1, 0, NULL);
270+
tsrm_ls = ts_resource(0);
271+
#endif
272+
273+
#ifdef NXT_PHP7
274+
#if defined(ZEND_SIGNALS) || PHP_MINOR_VERSION > 0
275+
zend_signal_startup();
276+
#endif
277+
#endif
278+
265279
sapi_startup(&nxt_php_sapi_module);
266280

267281
if (c->options != NULL) {
@@ -433,7 +447,8 @@ nxt_php_alter_option(nxt_str_t *name, nxt_str_t *value, int type)
433447
if (ini_entry->on_modify
434448
&& ini_entry->on_modify(ini_entry, cstr, value->length,
435449
ini_entry->mh_arg1, ini_entry->mh_arg2,
436-
ini_entry->mh_arg3, ZEND_INI_STAGE_ACTIVATE)
450+
ini_entry->mh_arg3, ZEND_INI_STAGE_ACTIVATE
451+
TSRMLS_CC)
437452
!= SUCCESS)
438453
{
439454
nxt_free(cstr);
@@ -573,7 +588,11 @@ nxt_php_request_handler(nxt_unit_request_info_t *req)
573588
(char *) ctx->script.start);
574589
}
575590

591+
#if (NXT_PHP7)
576592
if (nxt_slow_path(php_request_startup() == FAILURE)) {
593+
#else
594+
if (nxt_slow_path(php_request_startup(TSRMLS_C) == FAILURE)) {
595+
#endif
577596
nxt_unit_req_debug(req, "php_request_startup() failed");
578597
rc = NXT_UNIT_ERROR;
579598

@@ -915,7 +934,7 @@ static void
915934
nxt_php_log_message(char *message, int syslog_type_int)
916935
#else
917936
static void
918-
nxt_php_log_message(char *message)
937+
nxt_php_log_message(char *message TSRMLS_DC)
919938
#endif
920939
{
921940
nxt_log(nxt_php_task, NXT_LOG_NOTICE, "php message: %s", message);

0 commit comments

Comments
 (0)