diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-02-22 15:09:59 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-02-22 15:09:59 +0300 |
commit | 029942f4eb7196c2cff0d0e26bc6ff274138f7d8 (patch) | |
tree | f4686c4d7b9cd574fe94c6f4918479a580fecf75 /src/nxt_application.c | |
parent | 059a8642898a6bd4b47d13a1c1d599cd44af7e1c (diff) | |
download | unit-029942f4eb7196c2cff0d0e26bc6ff274138f7d8.tar.gz unit-029942f4eb7196c2cff0d0e26bc6ff274138f7d8.tar.bz2 |
I/O operations refactoring.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_application.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/nxt_application.c b/src/nxt_application.c index 64886cf9..e0e5ffc7 100644 --- a/src/nxt_application.c +++ b/src/nxt_application.c @@ -20,7 +20,6 @@ static void nxt_app_conn_update(nxt_thread_t *thr, nxt_event_conn_t *c, nxt_log_t *log); static nxt_int_t nxt_app_write_finish(nxt_app_request_t *r); static void nxt_app_buf_send(nxt_event_conn_t *c, nxt_buf_t *out); -static void nxt_app_buf_completion(nxt_task_t *task, void *obj, void *data); static void nxt_app_delivery_handler(nxt_task_t *task, void *obj, void *data); static void nxt_app_delivery_ready(nxt_task_t *task, void *obj, void *data); static void nxt_app_delivery_completion(nxt_task_t *task, void *obj, @@ -683,7 +682,7 @@ nxt_app_write(nxt_app_request_t *r, const u_char *data, size_t length) nxt_buf_mem_init(b, start, 4096); - b->completion_handler = nxt_app_buf_completion; + b->completion_handler = NULL; nxt_app_buf_current_number++; } @@ -713,7 +712,7 @@ nxt_app_write_finish(nxt_app_request_t *r) return NXT_ERROR; } - b->completion_handler = nxt_app_buf_completion; + b->completion_handler = NULL; b->parent = (nxt_buf_t *) r; out = r->output_buf; @@ -746,20 +745,6 @@ nxt_app_buf_send(nxt_event_conn_t *c, nxt_buf_t *out) static void -nxt_app_buf_completion(nxt_task_t *task, void *obj, void *data) -{ - nxt_buf_t *b; - - b = obj; - - nxt_debug(task, "app buf completion"); - - b->next = nxt_app_buf_done; - nxt_app_buf_done = b; -} - - -static void nxt_app_delivery_handler(nxt_task_t *task, void *obj, void *data) { nxt_buf_t *b; @@ -797,14 +782,14 @@ nxt_app_delivery_handler(nxt_task_t *task, void *obj, void *data) c->write = b; c->write_state = &nxt_app_delivery_write_state; - nxt_event_conn_write(task, c); + nxt_event_conn_write(task->thread->engine, c); } static const nxt_event_conn_state_t nxt_app_delivery_write_state nxt_aligned(64) = { - NXT_EVENT_BUF_PROCESS, + NXT_EVENT_NO_BUF_PROCESS, NXT_EVENT_TIMER_AUTORESET, nxt_app_delivery_ready, @@ -820,12 +805,26 @@ static const nxt_event_conn_state_t nxt_app_delivery_write_state static void nxt_app_delivery_ready(nxt_task_t *task, void *obj, void *data) { + nxt_buf_t *b, *next; nxt_event_conn_t *c; c = obj; nxt_debug(task, "app delivery ready"); + for (b = c->write; b != NULL; b = next) { + + if (nxt_buf_is_mem(b)) { + if (b->mem.pos != b->mem.free) { + break; + } + } + + next = b->next; + b->next = nxt_app_buf_done; + nxt_app_buf_done = b; + } + nxt_work_queue_add(c->write_work_queue, nxt_app_delivery_completion, task, c, NULL); } |