summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2017-09-05 10:22:46 -0700
committerMax Romanov <max.romanov@nginx.com>2017-09-05 10:22:46 -0700
commitc937b8434ab603fa0d256f9fc29229bc76683301 (patch)
treea19102c5729dbe6ca7dcefe1abfd9d396c3a890d /src
parent1429cacd1738e6d3dde3a155228c4109de50984a (diff)
downloadunit-c937b8434ab603fa0d256f9fc29229bc76683301.tar.gz
unit-c937b8434ab603fa0d256f9fc29229bc76683301.tar.bz2
Double connection close attempt fix.
Diffstat (limited to '')
-rw-r--r--src/nxt_application.c4
-rw-r--r--src/nxt_router.c13
2 files changed, 13 insertions, 4 deletions
diff --git a/src/nxt_application.c b/src/nxt_application.c
index 232f5a7e..ef84a9ec 100644
--- a/src/nxt_application.c
+++ b/src/nxt_application.c
@@ -434,8 +434,8 @@ nxt_app_msg_write_get_buf(nxt_task_t *task, nxt_app_wmsg_t *msg, size_t size)
free_size = nxt_buf_mem_free_size(&b->mem);
if (nxt_slow_path(free_size < size)) {
- nxt_debug(task, "requested buffer too big (%z < %z)",
- free_size, size);
+ nxt_log(task, NXT_LOG_WARN, "requested buffer too big "
+ "(%z < %z)", free_size, size);
return NULL;
}
diff --git a/src/nxt_router.c b/src/nxt_router.c
index 3faca2c2..f557ebaf 100644
--- a/src/nxt_router.c
+++ b/src/nxt_router.c
@@ -2079,6 +2079,12 @@ nxt_router_gen_error(nxt_task_t *task, nxt_conn_t *c, int code,
c->socket.data = NULL;
}
+ if (c->socket.fd == -1) {
+ nxt_mp_release(c->mem_pool, b->next);
+ nxt_mp_release(c->mem_pool, b);
+ return;
+ }
+
if (c->write == NULL) {
c->write = b;
c->write_state = &nxt_router_conn_write_state;
@@ -2654,6 +2660,7 @@ nxt_router_process_http_request(nxt_task_t *task, nxt_conn_t *c,
nxt_debug(task, "req_id %uxD linked to conn %p at engine %p",
req_id, c, engine);
+ c->socket.data = NULL;
ra = nxt_router_ra_create(task, rc);
@@ -3118,9 +3125,11 @@ nxt_router_conn_error(nxt_task_t *task, void *obj, void *data)
nxt_debug(task, "router conn error");
- c->write_state = &nxt_router_conn_close_state;
+ if (c->socket.fd != -1) {
+ c->write_state = &nxt_router_conn_close_state;
- nxt_conn_close(task->thread->engine, c);
+ nxt_conn_close(task->thread->engine, c);
+ }
}