Moving request memory pool retain call after RPC data allocation.
If the call is done only after a successful RPC data allocation, its corresponding release call is not missed, which avoids a potential leak.
This commit is contained in:
@@ -326,18 +326,8 @@ nxt_http_action_t *
|
|||||||
nxt_http_application_handler(nxt_task_t *task, nxt_http_request_t *r,
|
nxt_http_application_handler(nxt_task_t *task, nxt_http_request_t *r,
|
||||||
nxt_http_action_t *action)
|
nxt_http_action_t *action)
|
||||||
{
|
{
|
||||||
nxt_event_engine_t *engine;
|
|
||||||
|
|
||||||
nxt_debug(task, "http application handler");
|
nxt_debug(task, "http application handler");
|
||||||
|
|
||||||
nxt_mp_retain(r->mem_pool);
|
|
||||||
|
|
||||||
engine = task->thread->engine;
|
|
||||||
r->timer.task = &engine->task;
|
|
||||||
r->timer.work_queue = &engine->fast_work_queue;
|
|
||||||
r->timer.log = engine->task.log;
|
|
||||||
r->timer.bias = NXT_TIMER_DEFAULT_BIAS;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: need an application flag to get local address
|
* TODO: need an application flag to get local address
|
||||||
* required by "SERVER_ADDR" in Pyhton and PHP. Not used in Go.
|
* required by "SERVER_ADDR" in Pyhton and PHP. Not used in Go.
|
||||||
|
|||||||
@@ -4705,6 +4705,21 @@ nxt_router_process_http_request(nxt_task_t *task, nxt_http_request_t *r,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* At this point we have request req_rpc_data allocated and registered
|
||||||
|
* in port handlers. Need to fixup request memory pool. Counterpart
|
||||||
|
* release will be called via following call chain:
|
||||||
|
* nxt_request_rpc_data_unlink() ->
|
||||||
|
* nxt_router_http_request_done() ->
|
||||||
|
* nxt_router_http_request_release()
|
||||||
|
*/
|
||||||
|
nxt_mp_retain(r->mem_pool);
|
||||||
|
|
||||||
|
r->timer.task = &engine->task;
|
||||||
|
r->timer.work_queue = &engine->fast_work_queue;
|
||||||
|
r->timer.log = engine->task.log;
|
||||||
|
r->timer.bias = NXT_TIMER_DEFAULT_BIAS;
|
||||||
|
|
||||||
req_rpc_data->stream = nxt_port_rpc_ex_stream(req_rpc_data);
|
req_rpc_data->stream = nxt_port_rpc_ex_stream(req_rpc_data);
|
||||||
req_rpc_data->app = app;
|
req_rpc_data->app = app;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user