diff options
author | Max Romanov <max.romanov@nginx.com> | 2017-10-04 15:00:35 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2017-10-04 15:00:35 +0300 |
commit | 730f5a9dd9b3674246d06d18e05c8899e018ef5f (patch) | |
tree | c4769942a0510eb5f802e4c1845dceaca2d3588b | |
parent | a4b5b5d45d26077ac822b25d5d26f58661c02dcf (diff) | |
download | unit-730f5a9dd9b3674246d06d18e05c8899e018ef5f.tar.gz unit-730f5a9dd9b3674246d06d18e05c8899e018ef5f.tar.bz2 |
Using request mem pool for req<->app link.
Request <-> application link structure (nxt_req_app_link_t) used to register
the request in application request queue (nxt_app_t.requests) and generate
application-specific port message.
Now it is allocated from request pool. This pool created for request parsing
and used to allocate and store information specific to this request.
-rw-r--r-- | src/nxt_application.c | 2 | ||||
-rw-r--r-- | src/nxt_router.c | 21 |
2 files changed, 20 insertions, 3 deletions
diff --git a/src/nxt_application.c b/src/nxt_application.c index 3b87dbf0..36e855b8 100644 --- a/src/nxt_application.c +++ b/src/nxt_application.c @@ -893,7 +893,7 @@ nxt_app_http_req_body_read(nxt_task_t *task, nxt_app_parse_ctx_t *ctx, nxt_int_t nxt_app_http_req_done(nxt_task_t *task, nxt_app_parse_ctx_t *ctx) { - nxt_mp_destroy(ctx->mem_pool); + nxt_mp_release(ctx->mem_pool, NULL); return NXT_OK; } diff --git a/src/nxt_router.c b/src/nxt_router.c index 63d11055..33b8d65e 100644 --- a/src/nxt_router.c +++ b/src/nxt_router.c @@ -31,6 +31,7 @@ typedef struct { nxt_conn_t *conn; nxt_app_t *app; nxt_port_t *app_port; + nxt_app_parse_ctx_t *ap; nxt_req_app_link_t *ra; nxt_queue_link_t link; /* for nxt_conn_t.requests */ @@ -320,7 +321,7 @@ nxt_router_ra_create(nxt_task_t *task, nxt_req_conn_link_t *rc) nxt_event_engine_t *engine; nxt_req_app_link_t *ra; - mp = rc->conn->mem_pool; + mp = rc->ap->mem_pool; engine = task->thread->engine; ra = nxt_mp_retain(mp, sizeof(nxt_req_app_link_t)); @@ -550,6 +551,12 @@ nxt_router_rc_unlink(nxt_task_t *task, nxt_req_conn_link_t *rc) rc->app = NULL; } + if (rc->ap != NULL) { + nxt_app_http_req_done(task, rc->ap); + + rc->ap = NULL; + } + nxt_queue_remove(&rc->link); rc->conn = NULL; @@ -3127,7 +3134,7 @@ nxt_router_process_http_request(nxt_task_t *task, nxt_conn_t *c, if (nxt_slow_path(rc == NULL)) { nxt_router_gen_error(task, c, 500, "Failed to allocate " - "req->conn link"); + "req<->conn link"); return; } @@ -3140,8 +3147,18 @@ 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); + rc->ap = ap; + c->socket.data = NULL; + ra = nxt_router_ra_create(task, rc); + if (nxt_slow_path(ra == NULL)) { + nxt_router_gen_error(task, c, 500, "Failed to allocate " + "req<->app link"); + + return; + } + ra->ap = ap; res = nxt_router_app_port(task, ra); |