diff options
author | Max Romanov <max.romanov@nginx.com> | 2017-08-02 13:21:32 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2017-08-02 13:21:32 +0300 |
commit | 9367dd2bf8982d7dbe5e8c71643d3e5d5ee494e1 (patch) | |
tree | eb8b27d0f4faa8f630b6d1ec935f369d478d56ba /src/nxt_port_socket.c | |
parent | bcf99f87e25d3702ec01595a5cf3e91c00cc6a98 (diff) | |
download | unit-9367dd2bf8982d7dbe5e8c71643d3e5d5ee494e1.tar.gz unit-9367dd2bf8982d7dbe5e8c71643d3e5d5ee494e1.tar.bz2 |
Implicit port read buffer completion.
To disable implicit completion, handler should reset msg->buf field.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_port_socket.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/nxt_port_socket.c b/src/nxt_port_socket.c index bdb37483..30c64a94 100644 --- a/src/nxt_port_socket.c +++ b/src/nxt_port_socket.c @@ -415,7 +415,11 @@ nxt_port_read_handler(nxt_task_t *task, void *obj, void *data) nxt_port_read_msg_process(task, port, &msg); - if (b->mem.pos == b->mem.free) { + /* + * To disable instant completion or buffer re-usage, + * handler should reset 'msg.buf'. + */ + if (msg.buf == b) { nxt_port_buf_free(port, b); } @@ -469,14 +473,23 @@ nxt_port_read_msg_process(nxt_task_t *task, nxt_port_t *port, port->handler(task, msg); if (msg->port_msg.mmap && orig_b != b) { - /* complete used mmap buffers */ - for (; b && nxt_buf_used_size(b) == 0; - b = b->next) { - nxt_debug(task, "complete buffer %p", b); - nxt_work_queue_add(port->socket.read_work_queue, - b->completion_handler, task, b, b->parent); + /* + * To disable instant buffer completion, + * handler should reset 'msg->buf'. + */ + if (msg->buf == b) { + /* complete mmap buffers */ + for (; b != NULL; b = b->next) { + nxt_debug(task, "complete buffer %p", b); + + nxt_work_queue_add(port->socket.read_work_queue, + b->completion_handler, task, b, b->parent); + } } + + /* restore original buf */ + msg->buf = orig_b; } return; |