From 4ae76249edb97775be8a0c749ad9ee79e3e85393 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Wed, 4 Oct 2017 14:57:29 +0300 Subject: Fixing memory leak when handling remove pid message. Worker threads ports need to receive 'remove pid' message to properly handle application process exit case and finish requests processed by particular application worker. Main process send 'remove pid' notification to service thread port only and this message must be 'proxied' to other running engines. Separate memory pool created for this message. For each engine structure required to post message to engine allocate from the pool using 'retain' allocation method. After successfull post structure will be freed using 'release' method. To completely destroy poll one more 'release' should be called to release initial reference count. I'm afraid this should be simplified using good old malloc() and free() calls. --- src/nxt_router.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/nxt_router.c b/src/nxt_router.c index 285c19b6..f923d72c 100644 --- a/src/nxt_router.c +++ b/src/nxt_router.c @@ -515,6 +515,8 @@ nxt_router_remove_pid_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) } nxt_queue_loop; + nxt_mp_release(mp, NULL); + msg->port_msg.type = _NXT_PORT_MSG_RPC_ERROR; nxt_port_rpc_handler(task, msg); -- cgit