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).
This commit is contained in:
Max Romanov
2019-02-28 13:39:31 +03:00
parent 4b92586530
commit 0c917b4d34

View File

@@ -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;
}