summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2020-04-14 16:11:13 +0300
committerMax Romanov <max.romanov@nginx.com>2020-04-14 16:11:13 +0300
commit9a422b8984a3ed462a2c35ba97fa8234f3a45591 (patch)
tree0ec2e9d540d7b9d7d74ad2dd6c288b606039baae
parent3c58a4bfc11d2d73fc72d1dbaeda4494d00508b8 (diff)
downloadunit-9a422b8984a3ed462a2c35ba97fa8234f3a45591.tar.gz
unit-9a422b8984a3ed462a2c35ba97fa8234f3a45591.tar.bz2
Completing chained shared memory buffers.
After 41331471eee7 completion handlers should complete next buffer in chain. Otherwise buffer memory may leak. Thanks to Peter Tkatchenko for reporing the issue and testing fixes.
-rw-r--r--src/nxt_port_memory.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/nxt_port_memory.c b/src/nxt_port_memory.c
index 24a40406..33d3777e 100644
--- a/src/nxt_port_memory.c
+++ b/src/nxt_port_memory.c
@@ -111,7 +111,7 @@ nxt_port_mmap_buf_completion(nxt_task_t *task, void *obj, void *data)
{
u_char *p;
nxt_mp_t *mp;
- nxt_buf_t *b;
+ nxt_buf_t *b, *next;
nxt_port_t *port;
nxt_process_t *process;
nxt_chunk_id_t c;
@@ -124,11 +124,12 @@ nxt_port_mmap_buf_completion(nxt_task_t *task, void *obj, void *data)
b = obj;
- mp = b->data;
-
nxt_assert(data == b->parent);
mmap_handler = data;
+
+complete_buf:
+
hdr = mmap_handler->hdr;
if (nxt_slow_path(hdr->src_pid != nxt_pid && hdr->dst_pid != nxt_pid)) {
@@ -184,8 +185,18 @@ release_buf:
nxt_port_mmap_handler_use(mmap_handler, -1);
+ next = b->next;
+ mp = b->data;
+
nxt_mp_free(mp, b);
nxt_mp_release(mp);
+
+ if (next != NULL) {
+ b = next;
+ mmap_handler = b->parent;
+
+ goto complete_buf;
+ }
}