summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_port.c
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2021-02-03 23:23:28 +0300
committerMax Romanov <max.romanov@nginx.com>2021-02-03 23:23:28 +0300
commit75a5dcfc4ec4f92a196c0cf3a187081a238a6b1d (patch)
tree148ef6c171b8ace5362f919d08895b4377bd6062 /src/nxt_port.c
parentb1685dbc769a1b62eedc3249697c30d8770fc8c3 (diff)
downloadunit-75a5dcfc4ec4f92a196c0cf3a187081a238a6b1d.tar.gz
unit-75a5dcfc4ec4f92a196c0cf3a187081a238a6b1d.tar.bz2
Fixing shared app queue unmap size.
Shared app queue takes more memory than port memory. To unmap all memory pages correct size need to be specified for munmap() call. Otherwise 4 Mb memory leaked on each configured application removal. The issue was introduced in 1d84b9e4b459.
Diffstat (limited to 'src/nxt_port.c')
-rw-r--r--src/nxt_port.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/nxt_port.c b/src/nxt_port.c
index dbcdec11..d4e46564 100644
--- a/src/nxt_port.c
+++ b/src/nxt_port.c
@@ -8,6 +8,7 @@
#include <nxt_runtime.h>
#include <nxt_port.h>
#include <nxt_router.h>
+#include <nxt_app_queue.h>
#include <nxt_port_queue.h>
@@ -84,6 +85,8 @@ nxt_port_new(nxt_task_t *task, nxt_port_id_t id, nxt_pid_t pid,
void
nxt_port_close(nxt_task_t *task, nxt_port_t *port)
{
+ size_t size;
+
nxt_debug(task, "port %p %d:%d close, type %d", port, port->pid,
port->id, port->type);
@@ -109,7 +112,10 @@ nxt_port_close(nxt_task_t *task, nxt_port_t *port)
}
if (port->queue != NULL) {
- nxt_mem_munmap(port->queue, sizeof(nxt_port_queue_t));
+ size = (port->id == (nxt_port_id_t) -1) ? sizeof(nxt_app_queue_t)
+ : sizeof(nxt_port_queue_t);
+ nxt_mem_munmap(port->queue, size);
+
port->queue = NULL;
}
}