summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_port_socket.c
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2019-02-28 13:39:31 +0300
committerMax Romanov <max.romanov@nginx.com>2019-02-28 13:39:31 +0300
commit0c917b4d348cc9ce78a6d4ad7bd4bddde739f402 (patch)
treec9e091275f9310c6d45a9b1f2e6d0febbbff9704 /src/nxt_port_socket.c
parent4b925865303de419af13f046eb4e3ebeb53a8a25 (diff)
downloadunit-0c917b4d348cc9ce78a6d4ad7bd4bddde739f402.tar.gz
unit-0c917b4d348cc9ce78a6d4ad7bd4bddde739f402.tar.bz2
Reusing fragmented message buffers.
Fragmented message non-mmap buffer chain not freed nor reused before this fix. This closes #206 on GitHub. Thanks to 洪志道 (Hong Zhi Dao).
Diffstat (limited to 'src/nxt_port_socket.c')
-rw-r--r--src/nxt_port_socket.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/nxt_port_socket.c b/src/nxt_port_socket.c
index a545013f..aed3a292 100644
--- a/src/nxt_port_socket.c
+++ b/src/nxt_port_socket.c
@@ -799,6 +799,14 @@ nxt_port_read_msg_process(nxt_task_t *task, nxt_port_t *port,
msg->buf = fmsg->buf;
msg->fd = fmsg->fd;
+
+ /*
+ * To disable instant completion or buffer re-usage,
+ * handler should reset 'msg.buf'.
+ */
+ if (!msg->port_msg.mmap && msg->buf == b) {
+ nxt_port_buf_free(port, b);
+ }
}
}
@@ -895,7 +903,7 @@ nxt_port_buf_alloc(nxt_port_t *port)
static void
nxt_port_buf_free(nxt_port_t *port, nxt_buf_t *b)
{
- b->next = port->free_bufs;
+ nxt_buf_chain_add(&b, port->free_bufs);
port->free_bufs = b;
}