summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorAndrei Belov <defan@nginx.com>2019-10-03 17:46:28 +0300
committerAndrei Belov <defan@nginx.com>2019-10-03 17:46:28 +0300
commit3dd3f861f4c3aa320aa137802f033f8f1fc7dc41 (patch)
tree357577c560920eb0f5837b7d073999f5c7a1a2cd /src
parent9de7aea721245cda9f079a2b29d8efaf99c440fd (diff)
parent59db9a3887211fccdaec04b7952ad0140090de22 (diff)
downloadunit-3dd3f861f4c3aa320aa137802f033f8f1fc7dc41.tar.gz
unit-3dd3f861f4c3aa320aa137802f033f8f1fc7dc41.tar.bz2
Merged with the default branch.
Diffstat (limited to '')
-rw-r--r--src/go/unit/response.go2
-rw-r--r--src/nxt_clone.c4
-rw-r--r--src/nxt_errno.h1
-rw-r--r--src/nxt_h1proto.c2
-rw-r--r--src/nxt_http_error.c18
-rw-r--r--src/nxt_http_parse.c59
-rw-r--r--src/nxt_http_parse.h1
-rw-r--r--src/nxt_http_static.c14
-rw-r--r--src/nxt_kqueue_engine.c5
-rw-r--r--src/nxt_main_process.c91
-rw-r--r--src/nxt_openssl.c16
-rw-r--r--src/nxt_php_sapi.c4
-rw-r--r--src/nxt_process.c57
-rw-r--r--src/test/nxt_http_parse_test.c22
14 files changed, 146 insertions, 150 deletions
diff --git a/src/go/unit/response.go b/src/go/unit/response.go
index 767d66b7..bb326ea5 100644
--- a/src/go/unit/response.go
+++ b/src/go/unit/response.go
@@ -63,7 +63,7 @@ func (r *response) WriteHeader(code int) {
for k, vv := range r.header {
for _, v := range vv {
fields++
- fields_size += len(k) + len(v)
+ fields_size += len(k) + len(v) + 2
}
}
diff --git a/src/nxt_clone.c b/src/nxt_clone.c
index 0fddd6c7..a2c376a3 100644
--- a/src/nxt_clone.c
+++ b/src/nxt_clone.c
@@ -127,9 +127,13 @@ nxt_clone_proc_map_write(nxt_task_t *task, const char *mapfile, pid_t pid,
nxt_errno);
}
+ close(mapfd);
+
return NXT_ERROR;
}
+ close(mapfd);
+
return NXT_OK;
}
diff --git a/src/nxt_errno.h b/src/nxt_errno.h
index e3ce8349..1b29ef2f 100644
--- a/src/nxt_errno.h
+++ b/src/nxt_errno.h
@@ -16,6 +16,7 @@ typedef int nxt_err_t;
#define NXT_ENOPATH ENOENT
#define NXT_ESRCH ESRCH
#define NXT_EINTR EINTR
+#define NXT_ENXIO ENXIO
#define NXT_ECHILD ECHILD
#define NXT_ENOMEM ENOMEM
#define NXT_EACCES EACCES
diff --git a/src/nxt_h1proto.c b/src/nxt_h1proto.c
index 39be4315..541fcb44 100644
--- a/src/nxt_h1proto.c
+++ b/src/nxt_h1proto.c
@@ -1293,7 +1293,7 @@ nxt_h1p_chunk_create(nxt_task_t *task, nxt_http_request_t *r, nxt_buf_t *out)
for (b = out; b != NULL; b = b->next) {
if (nxt_buf_is_last(b)) {
- tail = nxt_http_buf_mem(task, r, chunk_size);
+ tail = nxt_http_buf_mem(task, r, sizeof(tail_chunk));
if (nxt_slow_path(tail == NULL)) {
return NULL;
}
diff --git a/src/nxt_http_error.c b/src/nxt_http_error.c
index 1dcd8783..8e8b80f1 100644
--- a/src/nxt_http_error.c
+++ b/src/nxt_http_error.c
@@ -16,8 +16,12 @@ static const nxt_http_request_state_t nxt_http_request_send_error_body_state;
static const char error[] =
- "<html><head><title>Error</title></head>"
- "<body>Error.</body></html>\r\n";
+ "<!DOCTYPE html>"
+ "<title>Error %03d</title>"
+ "<p>Error %03d.\r\n";
+
+/* Two %03d (4 chars) patterns are replaced by status code (3 chars). */
+#define NXT_HTTP_ERROR_LEN (nxt_length(error) - 2)
void
@@ -49,7 +53,7 @@ nxt_http_request_error(nxt_task_t *task, nxt_http_request_t *r,
nxt_http_field_set(content_type, "Content-Type", "text/html");
r->resp.content_length = NULL;
- r->resp.content_length_n = nxt_length(error);
+ r->resp.content_length_n = NXT_HTTP_ERROR_LEN;
r->state = &nxt_http_request_send_error_body_state;
@@ -80,15 +84,13 @@ nxt_http_request_send_error_body(nxt_task_t *task, void *obj, void *data)
nxt_debug(task, "http request send error body");
- out = nxt_http_buf_mem(task, r, 0);
+ out = nxt_http_buf_mem(task, r, NXT_HTTP_ERROR_LEN);
if (nxt_slow_path(out == NULL)) {
goto fail;
}
- out->mem.start = (u_char *) error;
- out->mem.pos = out->mem.start;
- out->mem.free = out->mem.start + nxt_length(error);
- out->mem.end = out->mem.free;
+ out->mem.free = nxt_sprintf(out->mem.pos, out->mem.end, error,
+ r->status, r->status);
out->next = nxt_http_buf_last(r);
diff --git a/src/nxt_http_parse.c b/src/nxt_http_parse.c
index 5b009d96..e6e91454 100644
--- a/src/nxt_http_parse.c
+++ b/src/nxt_http_parse.c
@@ -162,7 +162,7 @@ static nxt_int_t
nxt_http_parse_request_line(nxt_http_request_parse_t *rp, u_char **pos,
u_char *end)
{
- u_char *p, ch, *after_slash, *exten, *args;
+ u_char *p, ch, *after_slash, *args;
nxt_int_t rc;
nxt_bool_t rest;
nxt_http_ver_t ver;
@@ -255,7 +255,6 @@ nxt_http_parse_request_line(nxt_http_request_parse_t *rp, u_char **pos,
rp->target_start = p;
after_slash = p + 1;
- exten = NULL;
args = NULL;
rest = 0;
@@ -274,7 +273,6 @@ continue_target:
}
after_slash = p + 1;
- exten = NULL;
continue;
case NXT_HTTP_TARGET_DOT:
@@ -283,7 +281,6 @@ continue_target:
goto rest_of_target;
}
- exten = p + 1;
continue;
case NXT_HTTP_TARGET_ARGS_MARK:
@@ -459,11 +456,6 @@ space_after_target:
rp->path.length = rp->target_end - rp->target_start;
}
- if (exten != NULL) {
- rp->exten.length = (rp->path.start + rp->path.length) - exten;
- rp->exten.start = exten;
- }
-
return nxt_http_parse_field_name(rp, pos, end);
}
@@ -846,7 +838,7 @@ static const uint8_t nxt_http_normal[32] nxt_aligned(32) = {
static nxt_int_t
nxt_http_parse_complex_target(nxt_http_request_parse_t *rp)
{
- u_char *p, *u, c, ch, high, *exten, *args;
+ u_char *p, *u, c, ch, high, *args;
enum {
sw_normal = 0,
@@ -872,7 +864,6 @@ nxt_http_parse_complex_target(nxt_http_request_parse_t *rp)
rp->path.start = u;
high = '\0';
- exten = NULL;
args = NULL;
while (p < rp->target_end) {
@@ -892,7 +883,6 @@ nxt_http_parse_complex_target(nxt_http_request_parse_t *rp)
switch (ch) {
case '/':
- exten = NULL;
state = sw_slash;
*u++ = ch;
continue;
@@ -905,10 +895,6 @@ nxt_http_parse_complex_target(nxt_http_request_parse_t *rp)
goto args;
case '#':
goto done;
- case '.':
- exten = u + 1;
- *u++ = ch;
- continue;
default:
*u++ = ch;
continue;
@@ -970,9 +956,11 @@ nxt_http_parse_complex_target(nxt_http_request_parse_t *rp)
state = sw_quoted;
continue;
case '?':
+ u--;
args = p;
goto args;
case '#':
+ u--;
goto done;
default:
state = sw_normal;
@@ -991,30 +979,42 @@ nxt_http_parse_complex_target(nxt_http_request_parse_t *rp)
}
switch (ch) {
+
case '/':
- state = sw_slash;
+ case '?':
+ case '#':
u -= 5;
+
for ( ;; ) {
if (u < rp->path.start) {
return NXT_HTTP_PARSE_INVALID;
}
+
if (*u == '/') {
u++;
break;
}
+
u--;
}
+
+ if (ch == '?') {
+ args = p;
+ goto args;
+ }
+
+ if (ch == '#') {
+ goto done;
+ }
+
+ state = sw_slash;
break;
case '%':
saved_state = state;
state = sw_quoted;
continue;
- case '?':
- args = p;
- goto args;
- case '#':
- goto done;
+
default:
state = sw_normal;
*u++ = ch;
@@ -1097,8 +1097,14 @@ nxt_http_parse_complex_target(nxt_http_request_parse_t *rp)
}
}
- if (state >= sw_quoted) {
- return NXT_HTTP_PARSE_INVALID;
+ if (state >= sw_dot) {
+ if (state >= sw_quoted) {
+ return NXT_HTTP_PARSE_INVALID;
+ }
+
+ /* "/." and "/.." must be normalized similar to "/./" and "/../". */
+ ch = '/';
+ goto again;
}
args:
@@ -1118,11 +1124,6 @@ done:
rp->path.length = u - rp->path.start;
- if (exten) {
- rp->exten.length = u - exten;
- rp->exten.start = exten;
- }
-
return NXT_OK;
}
diff --git a/src/nxt_http_parse.h b/src/nxt_http_parse.h
index a307ea73..d7ce5e4f 100644
--- a/src/nxt_http_parse.h
+++ b/src/nxt_http_parse.h
@@ -44,7 +44,6 @@ struct nxt_http_request_parse_s {
nxt_str_t path;
nxt_str_t args;
- nxt_str_t exten;
nxt_http_ver_t version;
diff --git a/src/nxt_http_static.c b/src/nxt_http_static.c
index 44b85389..48a989cf 100644
--- a/src/nxt_http_static.c
+++ b/src/nxt_http_static.c
@@ -94,9 +94,20 @@ nxt_http_static_handler(nxt_task_t *task, nxt_http_request_t *r,
if (nxt_slow_path(ret != NXT_OK)) {
switch (f->error) {
+ /*
+ * For Unix domain sockets "errno" is set to:
+ * - ENXIO on Linux;
+ * - EOPNOTSUPP on *BSD, MacOSX, and Solaris.
+ */
+
case NXT_ENOENT:
case NXT_ENOTDIR:
case NXT_ENAMETOOLONG:
+#if (NXT_LINUX)
+ case NXT_ENXIO:
+#else
+ case NXT_EOPNOTSUPP:
+#endif
level = NXT_LOG_ERR;
status = NXT_HTTP_NOT_FOUND;
break;
@@ -209,7 +220,6 @@ nxt_http_static_handler(nxt_task_t *task, nxt_http_request_t *r,
/* Not a file. */
nxt_file_close(task, f);
- f = NULL;
if (nxt_slow_path(!nxt_is_dir(&fi))) {
nxt_log(task, NXT_LOG_ERR, "\"%FN\" is not a regular file",
@@ -218,6 +228,8 @@ nxt_http_static_handler(nxt_task_t *task, nxt_http_request_t *r,
return NULL;
}
+ f = NULL;
+
r->status = NXT_HTTP_MOVED_PERMANENTLY;
r->resp.content_length_n = 0;
diff --git a/src/nxt_kqueue_engine.c b/src/nxt_kqueue_engine.c
index 0212b331..9edbc346 100644
--- a/src/nxt_kqueue_engine.c
+++ b/src/nxt_kqueue_engine.c
@@ -705,7 +705,10 @@ nxt_kqueue_poll(nxt_event_engine_t *engine, nxt_msec_t timeout)
nxt_log(&engine->task, level, "kevent(%d) failed %E",
engine->u.kqueue.fd, err);
- nxt_kqueue_error(engine);
+ if (err != NXT_EINTR) {
+ nxt_kqueue_error(engine);
+ }
+
return;
}
diff --git a/src/nxt_main_process.c b/src/nxt_main_process.c
index 44deb272..85685fbc 100644
--- a/src/nxt_main_process.c
+++ b/src/nxt_main_process.c
@@ -14,10 +14,6 @@
#include <nxt_cert.h>
#endif
-#ifdef NXT_LINUX
-#include <linux/sched.h>
-#endif
-
typedef struct {
nxt_socket_t socket;
@@ -661,7 +657,7 @@ nxt_main_start_worker_process(nxt_task_t *task, nxt_runtime_t *rt,
ret = nxt_user_cred_get(task, init->user_cred, group);
if (ret != NXT_OK) {
- return NXT_ERROR;
+ goto fail;
}
} else {
@@ -670,7 +666,7 @@ nxt_main_start_worker_process(nxt_task_t *task, nxt_runtime_t *rt,
{
nxt_alert(task, "cannot set user \"%V\" for app \"%V\": "
"missing capabilities", &app_conf->user, &app_conf->name);
- return NXT_ERROR;
+ goto fail;
}
if (app_conf->group.length > 0
@@ -680,7 +676,7 @@ nxt_main_start_worker_process(nxt_task_t *task, nxt_runtime_t *rt,
nxt_alert(task, "cannot set group \"%V\" for app \"%V\": "
"missing capabilities", &app_conf->group,
&app_conf->name);
- return NXT_ERROR;
+ goto fail;
}
last = nxt_pointer_to(init, sizeof(nxt_process_init_t));
@@ -702,10 +698,16 @@ nxt_main_start_worker_process(nxt_task_t *task, nxt_runtime_t *rt,
ret = nxt_init_set_isolation(task, init, app_conf->isolation);
if (nxt_slow_path(ret != NXT_OK)) {
- return NXT_ERROR;
+ goto fail;
}
return nxt_main_create_worker_process(task, rt, init);
+
+fail:
+
+ nxt_free(init);
+
+ return NXT_ERROR;
}
@@ -1012,52 +1014,50 @@ nxt_main_cleanup_worker_process(nxt_task_t *task, nxt_pid_t pid)
nxt_process_close_ports(task, process);
- if (!nxt_exiting) {
- nxt_runtime_process_each(rt, process) {
-
- if (process->pid == nxt_pid
- || process->pid == pid
- || nxt_queue_is_empty(&process->ports))
- {
- continue;
- }
-
- port = nxt_process_port_first(process);
+ if (nxt_exiting) {
+ if (rt->nprocesses <= 2) {
+ nxt_runtime_quit(task, 0);
+ }
- if (nxt_proc_remove_notify_matrix[ptype][port->type] == 0) {
- continue;
- }
+ return;
+ }
- buf = nxt_buf_mem_ts_alloc(task, task->thread->engine->mem_pool,
- sizeof(pid));
- if (nxt_slow_path(buf == NULL)) {
- continue;
- }
+ nxt_runtime_process_each(rt, process) {
- buf->mem.free = nxt_cpymem(buf->mem.free, &pid, sizeof(pid));
+ if (process->pid == nxt_pid
+ || process->pid == pid
+ || nxt_queue_is_empty(&process->ports))
+ {
+ continue;
+ }
- nxt_port_socket_write(task, port, NXT_PORT_MSG_REMOVE_PID,
- -1, init->stream, 0, buf);
- } nxt_runtime_process_loop;
- }
+ port = nxt_process_port_first(process);
- if (nxt_exiting) {
+ if (nxt_proc_remove_notify_matrix[ptype][port->type] == 0) {
+ continue;
+ }
- if (rt->nprocesses == 2) {
- nxt_runtime_quit(task, 0);
+ buf = nxt_buf_mem_ts_alloc(task, task->thread->engine->mem_pool,
+ sizeof(pid));
+ if (nxt_slow_path(buf == NULL)) {
+ continue;
}
- } else if (init != NULL) {
- if (init->restart != NULL) {
- if (init->type == NXT_PROCESS_ROUTER) {
- nxt_main_stop_worker_processes(task, rt);
- }
+ buf->mem.free = nxt_cpymem(buf->mem.free, &pid, sizeof(pid));
- init->restart(task, rt, init);
+ nxt_port_socket_write(task, port, NXT_PORT_MSG_REMOVE_PID,
+ -1, init->stream, 0, buf);
+ } nxt_runtime_process_loop;
- } else {
- nxt_free(init);
+ if (init->restart != NULL) {
+ if (init->type == NXT_PROCESS_ROUTER) {
+ nxt_main_stop_worker_processes(task, rt);
}
+
+ init->restart(task, rt, init);
+
+ } else {
+ nxt_free(init);
}
}
}
@@ -1311,6 +1311,11 @@ nxt_main_port_modules_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
return;
}
+ if (nxt_exiting) {
+ nxt_debug(task, "ignoring discovered modules, exiting");
+ return;
+ }
+
port = nxt_runtime_port_find(task->thread->runtime, msg->port_msg.pid,
msg->port_msg.reply_port);
diff --git a/src/nxt_openssl.c b/src/nxt_openssl.c
index c01f92c8..53ed0381 100644
--- a/src/nxt_openssl.c
+++ b/src/nxt_openssl.c
@@ -599,7 +599,6 @@ nxt_openssl_conn_handshake(nxt_task_t *task, void *obj, void *data)
default:
case NXT_ERROR:
- c->socket.error = err;
nxt_openssl_conn_error(task, err, "SSL_do_handshake(%d) failed",
c->socket.fd);
@@ -644,7 +643,6 @@ nxt_openssl_conn_io_recvbuf(nxt_conn_t *c, nxt_buf_t *b)
n = nxt_openssl_conn_test_error(c->socket.task, c, ret, err,
NXT_OPENSSL_READ);
if (n == NXT_ERROR) {
- c->socket.error = err;
nxt_openssl_conn_error(c->socket.task, err,
"SSL_read(%d, %p, %uz) failed",
c->socket.fd, b->mem.free, size);
@@ -684,13 +682,7 @@ nxt_openssl_conn_io_send(nxt_task_t *task, nxt_sendbuf_t *sb, void *buf,
ret = SSL_write(tls->session, buf, size);
- if (ret <= 0) {
- err = nxt_socket_errno;
- sb->error = err;
-
- } else {
- err = 0;
- }
+ err = (ret <= 0) ? nxt_socket_errno : 0;
nxt_debug(task, "SSL_write(%d, %p, %uz): %d err:%d",
sb->socket, buf, size, ret, err);
@@ -701,15 +693,13 @@ nxt_openssl_conn_io_send(nxt_task_t *task, nxt_sendbuf_t *sb, void *buf,
c = tls->conn;
c->socket.write_ready = sb->ready;
- c->socket.error = sb->error;
n = nxt_openssl_conn_test_error(task, c, ret, err, NXT_OPENSSL_WRITE);
sb->ready = c->socket.write_ready;
- sb->error = c->socket.error;
if (n == NXT_ERROR) {
- sb->error = err;
+ sb->error = c->socket.error;
nxt_openssl_conn_error(task, err, "SSL_write(%d, %p, %uz) failed",
sb->socket, buf, size);
}
@@ -825,7 +815,6 @@ nxt_openssl_conn_io_shutdown(nxt_task_t *task, void *obj, void *data)
default:
case NXT_ERROR:
- c->socket.error = err;
nxt_openssl_conn_error(task, err, "SSL_shutdown(%d) failed",
c->socket.fd);
handler = c->write_state->error_handler;
@@ -886,6 +875,7 @@ nxt_openssl_conn_test_error(nxt_task_t *task, nxt_conn_t *c, int ret,
nxt_debug(task, "ERR_peek_error(): %l", lib_err);
if (sys_err != 0 || lib_err != 0) {
+ c->socket.error = sys_err;
return NXT_ERROR;
}
diff --git a/src/nxt_php_sapi.c b/src/nxt_php_sapi.c
index f5f115f5..7a5e0a3b 100644
--- a/src/nxt_php_sapi.c
+++ b/src/nxt_php_sapi.c
@@ -668,10 +668,10 @@ nxt_php_request_handler(nxt_unit_request_info_t *req)
SG(request_info).path_translated = NULL;
+ nxt_memzero(&file_handle, sizeof(file_handle));
+
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.filename = (char *) ctx->script_filename.start;
- file_handle.free_filename = 0;
- file_handle.opened_path = NULL;
nxt_unit_req_debug(req, "handle.filename = '%s'",
ctx->script_filename.start);
diff --git a/src/nxt_process.c b/src/nxt_process.c
index 638765a4..0cc9ccc4 100644
--- a/src/nxt_process.c
+++ b/src/nxt_process.c
@@ -42,7 +42,8 @@ nxt_bool_t nxt_proc_remove_notify_matrix[NXT_PROCESS_MAX][NXT_PROCESS_MAX] = {
static nxt_int_t
-nxt_process_worker_setup(nxt_task_t *task, nxt_process_t *process, int parentfd) {
+nxt_process_worker_setup(nxt_task_t *task, nxt_process_t *process, int parentfd)
+{
pid_t rpid, pid;
ssize_t n;
nxt_int_t parent_status;
@@ -87,11 +88,6 @@ nxt_process_worker_setup(nxt_task_t *task, nxt_process_t *process, int parentfd)
return NXT_ERROR;
}
- if (nxt_slow_path(close(parentfd) == -1)) {
- nxt_alert(task, "failed to close reader pipe fd");
- return NXT_ERROR;
- }
-
if (nxt_slow_path(parent_status != NXT_OK)) {
return parent_status;
}
@@ -152,29 +148,26 @@ nxt_process_create(nxt_task_t *task, nxt_process_t *process)
init = process->init;
#if (NXT_HAVE_CLONE)
- pid = nxt_clone(SIGCHLD|init->isolation.clone.flags);
-#else
- pid = fork();
-#endif
-
+ pid = nxt_clone(SIGCHLD | init->isolation.clone.flags);
if (nxt_slow_path(pid < 0)) {
-#if (NXT_HAVE_CLONE)
nxt_alert(task, "clone() failed while creating \"%s\" %E",
init->name, nxt_errno);
+ goto cleanup;
+ }
#else
+ pid = fork();
+ if (nxt_slow_path(pid < 0)) {
nxt_alert(task, "fork() failed while creating \"%s\" %E",
init->name, nxt_errno);
-#endif
-
- return pid;
+ goto cleanup;
}
+#endif
if (pid == 0) {
/* Child. */
if (nxt_slow_path(close(pipefd[1]) == -1)) {
nxt_alert(task, "failed to close writer pipe fd");
- return NXT_ERROR;
}
ret = nxt_process_worker_setup(task, process, pipefd[0]);
@@ -182,6 +175,10 @@ nxt_process_create(nxt_task_t *task, nxt_process_t *process)
exit(1);
}
+ if (nxt_slow_path(close(pipefd[0]) == -1)) {
+ nxt_alert(task, "failed to close writer pipe fd");
+ }
+
/*
* Explicitly return 0 to notice the caller function this is the child.
* The caller must return to the event engine work queue loop.
@@ -191,10 +188,6 @@ nxt_process_create(nxt_task_t *task, nxt_process_t *process)
/* Parent. */
- if (nxt_slow_path(close(pipefd[0]) != 0)) {
- nxt_alert(task, "failed to close pipe: %E", nxt_errno);
- }
-
/*
* At this point, the child process is blocked reading the
* pipe fd to get its real pid (rpid).
@@ -211,14 +204,14 @@ nxt_process_create(nxt_task_t *task, nxt_process_t *process)
if (nxt_slow_path(write(pipefd[1], &pid, sizeof(pid)) == -1)) {
nxt_alert(task, "failed to write real pid");
- goto fail_cleanup;
+ goto fail;
}
#if (NXT_HAVE_CLONE_NEWUSER)
if ((init->isolation.clone.flags & CLONE_NEWUSER) == CLONE_NEWUSER) {
ret = nxt_clone_proc_map(task, pid, &init->isolation.clone);
if (nxt_slow_path(ret != NXT_OK)) {
- goto fail_cleanup;
+ goto fail;
}
}
#endif
@@ -227,16 +220,16 @@ nxt_process_create(nxt_task_t *task, nxt_process_t *process)
if (nxt_slow_path(write(pipefd[1], &ret, sizeof(ret)) == -1)) {
nxt_alert(task, "failed to write status");
- goto fail_cleanup;
+ goto fail;
}
process->pid = pid;
nxt_runtime_process_add(task, process);
- return pid;
+ goto cleanup;
-fail_cleanup:
+fail:
ret = NXT_ERROR;
@@ -244,13 +237,21 @@ fail_cleanup:
nxt_alert(task, "failed to write status");
}
- if (nxt_slow_path(close(pipefd[1]) != 0)) {
+ waitpid(pid, NULL, 0);
+
+ pid = -1;
+
+cleanup:
+
+ if (nxt_slow_path(close(pipefd[0]) != 0)) {
nxt_alert(task, "failed to close pipe: %E", nxt_errno);
}
- waitpid(pid, NULL, 0);
+ if (nxt_slow_path(close(pipefd[1]) != 0)) {
+ nxt_alert(task, "failed to close pipe: %E", nxt_errno);
+ }
- return -1;
+ return pid;
}
diff --git a/src/test/nxt_http_parse_test.c b/src/test/nxt_http_parse_test.c
index 5498cb1f..8dcbc061 100644
--- a/src/test/nxt_http_parse_test.c
+++ b/src/test/nxt_http_parse_test.c
@@ -11,7 +11,6 @@
typedef struct {
nxt_str_t method;
nxt_str_t target;
- nxt_str_t exten;
nxt_str_t args;
u_char version[8];
@@ -66,7 +65,6 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
nxt_string("GET"),
nxt_string("/"),
nxt_null_string,
- nxt_null_string,
"HTTP/1.0",
0, 0, 0
}}
@@ -78,7 +76,6 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
{ .request_line = {
nxt_string("XXX-METHOD"),
nxt_string("/d.ir/fi+le.ext?key=val"),
- nxt_string("ext"),
nxt_string("key=val"),
"HTTP/1.2",
0, 0, 0
@@ -91,7 +88,6 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
{ .request_line = {
nxt_string("GET"),
nxt_string("/di.r/?"),
- nxt_null_string,
nxt_string(""),
"HTTP/1.0",
0, 0, 0
@@ -135,7 +131,6 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
nxt_string("GET"),
nxt_string("/."),
nxt_null_string,
- nxt_null_string,
"HTTP/1.0",
1, 0, 0
}}
@@ -148,7 +143,6 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
nxt_string("GET"),
nxt_string("/#"),
nxt_null_string,
- nxt_null_string,
"HTTP/1.0",
1, 0, 0
}}
@@ -160,7 +154,6 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
{ .request_line = {
nxt_string("GET"),
nxt_string("/?#"),
- nxt_null_string,
nxt_string(""),
"HTTP/1.0",
1, 0, 0
@@ -174,7 +167,6 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
nxt_string("GET"),
nxt_string("//"),
nxt_null_string,
- nxt_null_string,
"HTTP/1.0",
1, 0, 0
}}
@@ -187,7 +179,6 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
nxt_string("GET"),
nxt_string("/%20"),
nxt_null_string,
- nxt_null_string,
"HTTP/1.0",
0, 1, 0
}}
@@ -200,7 +191,6 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
nxt_string("GET"),
nxt_string("/ a"),
nxt_null_string,
- nxt_null_string,
"HTTP/1.0",
0, 0, 1
}}
@@ -212,7 +202,6 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
{ .request_line = {
nxt_string("GET"),
nxt_string("/na %20me.ext?args"),
- nxt_string("ext"),
nxt_string("args"),
"HTTP/1.0",
0, 1, 1
@@ -225,7 +214,6 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = {
{ .request_line = {
nxt_string("GET"),
nxt_string("/ HTTP/1.0"),
- nxt_string("0"),
nxt_null_string,
"HTTP/1.1",
0, 0, 1
@@ -740,16 +728,6 @@ nxt_http_parse_test_request_line(nxt_http_request_parse_t *rp,
return NXT_ERROR;
}
- if (rp->exten.start != test->exten.start
- && !nxt_strstr_eq(&rp->exten, &test->exten))
- {
- nxt_log_alert(log, "http parse test case failed:\n"
- " - request:\n\"%V\"\n"
- " - exten: \"%V\" (expected: \"%V\")",
- request, &rp->exten, &test->exten);
- return NXT_ERROR;
- }
-
if (rp->args.start != test->args.start
&& !nxt_strstr_eq(&rp->args, &test->args))
{