nxt_php_sapi.c (743:e0f0cd7d244a) nxt_php_sapi.c (857:3fd76e4ce70a)
1/*
2 * Copyright (C) Max Romanov
3 * Copyright (C) Valentin V. Bartenev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include "php.h"
8#include "SAPI.h"

--- 31 unchanged lines hidden (view full) ---

40# endif
41#endif
42
43static int nxt_php_startup(sapi_module_struct *sapi_module);
44static void nxt_php_set_options(nxt_task_t *task, nxt_conf_value_t *options,
45 int type);
46static nxt_int_t nxt_php_alter_option(nxt_str_t *name, nxt_str_t *value,
47 int type);
1/*
2 * Copyright (C) Max Romanov
3 * Copyright (C) Valentin V. Bartenev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include "php.h"
8#include "SAPI.h"

--- 31 unchanged lines hidden (view full) ---

40# endif
41#endif
42
43static int nxt_php_startup(sapi_module_struct *sapi_module);
44static void nxt_php_set_options(nxt_task_t *task, nxt_conf_value_t *options,
45 int type);
46static nxt_int_t nxt_php_alter_option(nxt_str_t *name, nxt_str_t *value,
47 int type);
48static int nxt_php_send_headers(sapi_headers_struct *sapi_headers);
49static char *nxt_php_read_cookies(void);
48static int nxt_php_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC);
49static char *nxt_php_read_cookies(TSRMLS_D);
50static void nxt_php_set_sptr(nxt_unit_request_info_t *req, const char *name,
51 nxt_unit_sptr_t *v, uint32_t len, zval *track_vars_array TSRMLS_DC);
52nxt_inline void nxt_php_set_str(nxt_unit_request_info_t *req, const char *name,
53 nxt_str_t *s, zval *track_vars_array TSRMLS_DC);
54static void nxt_php_set_cstr(nxt_unit_request_info_t *req, const char *name,
55 char *str, uint32_t len, zval *track_vars_array TSRMLS_DC);
50static void nxt_php_set_sptr(nxt_unit_request_info_t *req, const char *name,
51 nxt_unit_sptr_t *v, uint32_t len, zval *track_vars_array TSRMLS_DC);
52nxt_inline void nxt_php_set_str(nxt_unit_request_info_t *req, const char *name,
53 nxt_str_t *s, zval *track_vars_array TSRMLS_DC);
54static void nxt_php_set_cstr(nxt_unit_request_info_t *req, const char *name,
55 char *str, uint32_t len, zval *track_vars_array TSRMLS_DC);
56static void nxt_php_register_variables(zval *track_vars_array);
56static void nxt_php_register_variables(zval *track_vars_array TSRMLS_DC);
57#ifdef NXT_HAVE_PHP_LOG_MESSAGE_WITH_SYSLOG_TYPE
58static void nxt_php_log_message(char *message, int syslog_type_int);
59#else
57#ifdef NXT_HAVE_PHP_LOG_MESSAGE_WITH_SYSLOG_TYPE
58static void nxt_php_log_message(char *message, int syslog_type_int);
59#else
60static void nxt_php_log_message(char *message);
60static void nxt_php_log_message(char *message TSRMLS_DC);
61#endif
62
63#ifdef NXT_PHP7
64static size_t nxt_php_unbuffered_write(const char *str,
65 size_t str_length TSRMLS_DC);
66static size_t nxt_php_read_post(char *buffer, size_t count_bytes TSRMLS_DC);
67#else
68static int nxt_php_unbuffered_write(const char *str, uint str_length TSRMLS_DC);

--- 85 unchanged lines hidden (view full) ---

154 compat,
155 nxt_string("php"),
156 PHP_VERSION,
157 nxt_php_init,
158};
159
160
161static nxt_task_t *nxt_php_task;
61#endif
62
63#ifdef NXT_PHP7
64static size_t nxt_php_unbuffered_write(const char *str,
65 size_t str_length TSRMLS_DC);
66static size_t nxt_php_read_post(char *buffer, size_t count_bytes TSRMLS_DC);
67#else
68static int nxt_php_unbuffered_write(const char *str, uint str_length TSRMLS_DC);

--- 85 unchanged lines hidden (view full) ---

154 compat,
155 nxt_string("php"),
156 PHP_VERSION,
157 nxt_php_init,
158};
159
160
161static nxt_task_t *nxt_php_task;
162#ifdef ZTS
163static void ***tsrm_ls;
164#endif
162
163
164static nxt_int_t
165nxt_php_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
166{
167 u_char *p;
168 nxt_str_t rpath, ini_path;
169 nxt_str_t *root, *path, *script, *index;

--- 87 unchanged lines hidden (view full) ---

257 index->start = nxt_malloc(index->length);
258 if (nxt_slow_path(index->start == NULL)) {
259 return NXT_ERROR;
260 }
261
262 nxt_memcpy(index->start, c->index.start, c->index.length);
263 }
264
165
166
167static nxt_int_t
168nxt_php_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
169{
170 u_char *p;
171 nxt_str_t rpath, ini_path;
172 nxt_str_t *root, *path, *script, *index;

--- 87 unchanged lines hidden (view full) ---

260 index->start = nxt_malloc(index->length);
261 if (nxt_slow_path(index->start == NULL)) {
262 return NXT_ERROR;
263 }
264
265 nxt_memcpy(index->start, c->index.start, c->index.length);
266 }
267
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
265 sapi_startup(&nxt_php_sapi_module);
266
267 if (c->options != NULL) {
268 value = nxt_conf_get_object_member(c->options, &file_str, NULL);
269
270 if (value != NULL) {
271 nxt_conf_get_string(value, &ini_path);
272

--- 155 unchanged lines hidden (view full) ---

428 }
429
430 nxt_memcpy(cstr, value->start, value->length);
431 cstr[value->length] = '\0';
432
433 if (ini_entry->on_modify
434 && ini_entry->on_modify(ini_entry, cstr, value->length,
435 ini_entry->mh_arg1, ini_entry->mh_arg2,
279 sapi_startup(&nxt_php_sapi_module);
280
281 if (c->options != NULL) {
282 value = nxt_conf_get_object_member(c->options, &file_str, NULL);
283
284 if (value != NULL) {
285 nxt_conf_get_string(value, &ini_path);
286

--- 155 unchanged lines hidden (view full) ---

442 }
443
444 nxt_memcpy(cstr, value->start, value->length);
445 cstr[value->length] = '\0';
446
447 if (ini_entry->on_modify
448 && ini_entry->on_modify(ini_entry, cstr, value->length,
449 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)
437 != SUCCESS)
438 {
439 nxt_free(cstr);
440 return NXT_ERROR;
441 }
442
443 ini_entry->value = cstr;
444 ini_entry->value_length = value->length;

--- 123 unchanged lines hidden (view full) ---

568 (int) nxt_php_path.length,
569 (char *) nxt_php_path.start);
570
571 } else {
572 nxt_unit_req_debug(req, "run script %.*s", (int) ctx->script.length,
573 (char *) ctx->script.start);
574 }
575
452 != SUCCESS)
453 {
454 nxt_free(cstr);
455 return NXT_ERROR;
456 }
457
458 ini_entry->value = cstr;
459 ini_entry->value_length = value->length;

--- 123 unchanged lines hidden (view full) ---

583 (int) nxt_php_path.length,
584 (char *) nxt_php_path.start);
585
586 } else {
587 nxt_unit_req_debug(req, "run script %.*s", (int) ctx->script.length,
588 (char *) ctx->script.start);
589 }
590
591#if (NXT_PHP7)
576 if (nxt_slow_path(php_request_startup() == FAILURE)) {
592 if (nxt_slow_path(php_request_startup() == FAILURE)) {
593#else
594 if (nxt_slow_path(php_request_startup(TSRMLS_C) == FAILURE)) {
595#endif
577 nxt_unit_req_debug(req, "php_request_startup() failed");
578 rc = NXT_UNIT_ERROR;
579
580 goto fail;
581 }
582
583 rc = NXT_UNIT_OK;
584

--- 325 unchanged lines hidden (view full) ---

910}
911
912
913#ifdef NXT_HAVE_PHP_LOG_MESSAGE_WITH_SYSLOG_TYPE
914static void
915nxt_php_log_message(char *message, int syslog_type_int)
916#else
917static void
596 nxt_unit_req_debug(req, "php_request_startup() failed");
597 rc = NXT_UNIT_ERROR;
598
599 goto fail;
600 }
601
602 rc = NXT_UNIT_OK;
603

--- 325 unchanged lines hidden (view full) ---

929}
930
931
932#ifdef NXT_HAVE_PHP_LOG_MESSAGE_WITH_SYSLOG_TYPE
933static void
934nxt_php_log_message(char *message, int syslog_type_int)
935#else
936static void
918nxt_php_log_message(char *message)
937nxt_php_log_message(char *message TSRMLS_DC)
919#endif
920{
921 nxt_log(nxt_php_task, NXT_LOG_NOTICE, "php message: %s", message);
922}
938#endif
939{
940 nxt_log(nxt_php_task, NXT_LOG_NOTICE, "php message: %s", message);
941}