summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_application.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/nxt_application.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/nxt_application.c b/src/nxt_application.c
index d795c230..30b9d1fa 100644
--- a/src/nxt_application.c
+++ b/src/nxt_application.c
@@ -772,21 +772,39 @@ static nxt_http_fields_hash_entry_t nxt_app_request_fields[] = {
};
-nxt_int_t
-nxt_app_http_req_init(nxt_task_t *task, nxt_app_parse_ctx_t *ctx)
+nxt_app_parse_ctx_t *
+nxt_app_http_req_init(nxt_task_t *task)
{
- nxt_int_t rc;
+ nxt_mp_t *mp;
+ nxt_int_t rc;
+ nxt_app_parse_ctx_t *ctx;
+
+ mp = nxt_mp_create(1024, 128, 256, 32);
+ if (nxt_slow_path(mp == NULL)) {
+ return NULL;
+ }
+
+ ctx = nxt_mp_retain(mp, sizeof(nxt_app_parse_ctx_t));
+ if (nxt_slow_path(ctx == NULL)) {
+ nxt_mp_destroy(mp);
- ctx->mem_pool = nxt_mp_create(1024, 128, 256, 32);
+ return NULL;
+ }
- rc = nxt_http_parse_request_init(&ctx->parser, ctx->mem_pool);
+ nxt_memzero(ctx, sizeof(nxt_app_parse_ctx_t));
+
+ ctx->mem_pool = mp;
+
+ rc = nxt_http_parse_request_init(&ctx->parser, mp);
if (nxt_slow_path(rc != NXT_OK)) {
- return rc;
+ nxt_mp_release(mp, ctx);
+
+ return NULL;
}
ctx->parser.fields_hash = nxt_app_request_fields_hash;
- return NXT_OK;
+ return ctx;
}
@@ -879,7 +897,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, ctx);
return NXT_OK;
}