diff options
author | Max Romanov <max.romanov@nginx.com> | 2020-08-09 10:26:19 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2020-08-09 10:26:19 +0300 |
commit | 3a721e1d96720505d4d6638e77d2c296d962519c (patch) | |
tree | 65f50df39ef9a550b97a9f3599542c81c0b24c61 /src/nxt_router.c | |
parent | 0f3abebd019130a6e4e69e53345f403ba802edfb (diff) | |
download | unit-3a721e1d96720505d4d6638e77d2c296d962519c.tar.gz unit-3a721e1d96720505d4d6638e77d2c296d962519c.tar.bz2 |
Fixing leaked configuration objects.
If there are no listen sockets, the router configuration usage counter
remains 0 and never decreases. The only moment to release a configuration is
right after a configuration update.
Diffstat (limited to 'src/nxt_router.c')
-rw-r--r-- | src/nxt_router.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/nxt_router.c b/src/nxt_router.c index 8b3f3daf..758310a9 100644 --- a/src/nxt_router.c +++ b/src/nxt_router.c @@ -1208,13 +1208,39 @@ nxt_router_conf_wait(nxt_task_t *task, void *obj, void *data) static void nxt_router_conf_ready(nxt_task_t *task, nxt_router_temp_conf_t *tmcf) { - nxt_debug(task, "temp conf count:%D", tmcf->count); + uint32_t count; + nxt_router_conf_t *rtcf; + nxt_thread_spinlock_t *lock; - if (--tmcf->count == 0) { - nxt_router_conf_send(task, tmcf, NXT_PORT_MSG_RPC_READY_LAST); + nxt_debug(task, "temp conf %p count: %D", tmcf, tmcf->count); - nxt_mp_destroy(tmcf->mem_pool); + if (--tmcf->count > 0) { + return; } + + nxt_router_conf_send(task, tmcf, NXT_PORT_MSG_RPC_READY_LAST); + + rtcf = tmcf->router_conf; + + lock = &rtcf->router->lock; + + nxt_thread_spin_lock(lock); + + count = rtcf->count; + + nxt_thread_spin_unlock(lock); + + nxt_debug(task, "rtcf %p: %D", rtcf, count); + + if (count == 0) { + nxt_http_routes_cleanup(task, rtcf->routes); + + nxt_router_access_log_release(task, lock, rtcf->access_log); + + nxt_mp_destroy(rtcf->mem_pool); + } + + nxt_mp_destroy(tmcf->mem_pool); } |