diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-05-31 15:26:45 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-05-31 15:26:45 +0300 |
commit | 5bc011afad76fe7576ef0e0ed7ca7eb5417cf338 (patch) | |
tree | 0db06be61c62ecabb5225f69688da8ab4424aa36 /src/nxt_event_conn.c | |
parent | dee819daabe6e7ab462beac779ab0dfd7d648844 (diff) | |
download | unit-5bc011afad76fe7576ef0e0ed7ca7eb5417cf338.tar.gz unit-5bc011afad76fe7576ef0e0ed7ca7eb5417cf338.tar.bz2 |
Skeleton of router configuration and request processing.
Diffstat (limited to 'src/nxt_event_conn.c')
-rw-r--r-- | src/nxt_event_conn.c | 128 |
1 files changed, 0 insertions, 128 deletions
diff --git a/src/nxt_event_conn.c b/src/nxt_event_conn.c index 079901f3..b8adb00a 100644 --- a/src/nxt_event_conn.c +++ b/src/nxt_event_conn.c @@ -7,12 +7,6 @@ #include <nxt_main.h> -static void nxt_conn_shutdown_handler(nxt_task_t *task, void *obj, void *data); -static void nxt_conn_close_handler(nxt_task_t *task, void *obj, void *data); -static void nxt_conn_close_timer_handler(nxt_task_t *task, void *obj, - void *data); - - nxt_event_conn_io_t nxt_unix_event_conn_io = { nxt_event_conn_io_connect, nxt_event_conn_io_accept, @@ -132,128 +126,6 @@ nxt_event_conn_io_shutdown(nxt_task_t *task, void *obj, void *data) void -nxt_event_conn_close(nxt_event_engine_t *engine, nxt_event_conn_t *c) -{ - int ret; - socklen_t len; - struct linger linger; - nxt_work_queue_t *wq; - nxt_work_handler_t handler; - - if (c->socket.timedout) { - /* - * Resetting of timed out connection on close - * releases kernel memory associated with socket. - * This also causes sending TCP/IP RST to a peer. - */ - linger.l_onoff = 1; - linger.l_linger = 0; - len = sizeof(struct linger); - - ret = setsockopt(c->socket.fd, SOL_SOCKET, SO_LINGER, &linger, len); - - if (nxt_slow_path(ret != 0)) { - nxt_log(c->socket.task, NXT_LOG_CRIT, - "setsockopt(%d, SO_LINGER) failed %E", - c->socket.fd, nxt_socket_errno); - } - } - - if (c->socket.error == 0 && !c->socket.closed && !c->socket.shutdown) { - wq = &engine->shutdown_work_queue; - handler = nxt_conn_shutdown_handler; - - } else{ - wq = &engine->close_work_queue; - handler = nxt_conn_close_handler; - } - - nxt_work_queue_add(wq, handler, c->socket.task, c, engine); -} - - -static void -nxt_conn_shutdown_handler(nxt_task_t *task, void *obj, void *data) -{ - nxt_event_conn_t *c; - nxt_event_engine_t *engine; - - c = obj; - engine = data; - - nxt_debug(task, "event conn shutdown fd:%d", c->socket.fd); - - c->socket.shutdown = 1; - - nxt_socket_shutdown(task, c->socket.fd, SHUT_RDWR); - - nxt_work_queue_add(&engine->close_work_queue, nxt_conn_close_handler, - task, c, engine); -} - - -static void -nxt_conn_close_handler(nxt_task_t *task, void *obj, void *data) -{ - nxt_uint_t events_pending, timers_pending; - nxt_event_conn_t *c; - nxt_event_engine_t *engine; - - c = obj; - engine = data; - - nxt_debug(task, "event conn close fd:%d", c->socket.fd); - - timers_pending = nxt_timer_delete(engine, &c->read_timer); - timers_pending += nxt_timer_delete(engine, &c->write_timer); - - events_pending = nxt_fd_event_close(engine, &c->socket); - - if (events_pending == 0) { - nxt_socket_close(task, c->socket.fd); - c->socket.fd = -1; - - if (timers_pending == 0) { - nxt_work_queue_add(&engine->fast_work_queue, - c->write_state->ready_handler, - task, c, c->socket.data); - return; - } - } - - c->write_timer.handler = nxt_conn_close_timer_handler; - c->write_timer.work_queue = &engine->fast_work_queue; - - nxt_timer_add(engine, &c->write_timer, 0); -} - - -static void -nxt_conn_close_timer_handler(nxt_task_t *task, void *obj, void *data) -{ - nxt_timer_t *ev; - nxt_event_conn_t *c; - nxt_event_engine_t *engine; - - ev = obj; - - c = nxt_event_write_timer_conn(ev); - - nxt_debug(task, "event conn close handler fd:%d", c->socket.fd); - - if (c->socket.fd != -1) { - nxt_socket_close(task, c->socket.fd); - c->socket.fd = -1; - } - - engine = task->thread->engine; - - nxt_work_queue_add(&engine->fast_work_queue, c->write_state->ready_handler, - task, c, c->socket.data); -} - - -void nxt_event_conn_timer(nxt_event_engine_t *engine, nxt_event_conn_t *c, const nxt_event_conn_state_t *state, nxt_timer_t *tev) { |