diff options
author | Max Romanov <max.romanov@nginx.com> | 2017-09-15 20:30:29 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2017-09-15 20:30:29 +0300 |
commit | 1449e27cb42a5b3ca2d2106a39fee3f1d54a340e (patch) | |
tree | a44a1ef5cb5cbf33424ab8b15085331a1d80b3ae /src/nxt_router.c | |
parent | 0bec14878e99de280046e1d1b1a0195e5478c808 (diff) | |
download | unit-1449e27cb42a5b3ca2d2106a39fee3f1d54a340e.tar.gz unit-1449e27cb42a5b3ca2d2106a39fee3f1d54a340e.tar.bz2 |
Fixing memory leak of request parse context.
Diffstat (limited to 'src/nxt_router.c')
-rw-r--r-- | src/nxt_router.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/nxt_router.c b/src/nxt_router.c index 7357667d..34078511 100644 --- a/src/nxt_router.c +++ b/src/nxt_router.c @@ -2791,15 +2791,10 @@ nxt_router_conn_http_header_parse(nxt_task_t *task, void *obj, void *data) nxt_debug(task, "router conn http header parse"); if (ap == NULL) { - ap = nxt_mp_zalloc(c->mem_pool, sizeof(nxt_app_parse_ctx_t)); + ap = nxt_app_http_req_init(task); if (nxt_slow_path(ap == NULL)) { - nxt_router_conn_close(task, c, data); - return; - } - - ret = nxt_app_http_req_init(task, ap); - if (nxt_slow_path(ret != NXT_OK)) { - nxt_router_conn_close(task, c, data); + nxt_router_gen_error(task, c, 500, + "Failed to allocate parse context"); return; } @@ -3003,8 +2998,6 @@ nxt_router_process_http_request(nxt_task_t *task, nxt_conn_t *c, nxt_debug(task, "stream #%uD linked to conn %p at engine %p", rc->stream, c, engine); - c->socket.data = NULL; - ra = nxt_router_ra_create(task, rc); ra->ap = ap; @@ -3451,12 +3444,20 @@ nxt_router_conn_free(nxt_task_t *task, void *obj, void *data) { nxt_conn_t *c; nxt_req_conn_link_t *rc; + nxt_app_parse_ctx_t *ap; nxt_socket_conf_joint_t *joint; c = obj; + ap = data; nxt_debug(task, "router conn close done"); + if (ap != NULL) { + nxt_app_http_req_done(task, ap); + + c->socket.data = NULL; + } + nxt_queue_each(rc, &c->requests, nxt_req_conn_link_t, link) { nxt_debug(task, "conn %p close, stream #%uD", c, rc->stream); |