diff options
author | Igor Sysoev <igor@sysoev.ru> | 2018-04-11 17:33:16 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2018-04-11 17:33:16 +0300 |
commit | 0be4f1f6938bf34c8ff5dacaf31716572404a10d (patch) | |
tree | 47c608f03f56c5f2fbf4601194dd4be7f1fc481f /src | |
parent | dc75c8395031254f84ee1b1bbe454b26d86a4266 (diff) | |
download | unit-0be4f1f6938bf34c8ff5dacaf31716572404a10d.tar.gz unit-0be4f1f6938bf34c8ff5dacaf31716572404a10d.tar.bz2 |
Keepalive processing optimization.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_h1proto.c | 55 |
1 files changed, 9 insertions, 46 deletions
diff --git a/src/nxt_h1proto.c b/src/nxt_h1proto.c index 7443985b..38766c31 100644 --- a/src/nxt_h1proto.c +++ b/src/nxt_h1proto.c @@ -40,7 +40,6 @@ static void nxt_h1p_request_discard(nxt_task_t *task, nxt_http_request_t *r, static void nxt_h1p_request_close(nxt_task_t *task, nxt_http_proto_t proto); static void nxt_h1p_keepalive(nxt_task_t *task, nxt_h1proto_t *h1p, nxt_conn_t *c); -static void nxt_h1p_conn_keepalive(nxt_task_t *task, void *obj, void *data); static void nxt_h1p_conn_error(nxt_task_t *task, void *obj, void *data); static void nxt_h1p_conn_timeout(nxt_task_t *task, void *obj, void *data); static void nxt_h1p_close(nxt_task_t *task, nxt_conn_t *c); @@ -55,7 +54,6 @@ static nxt_msec_t nxt_h1p_conn_timeout_value(nxt_conn_t *c, uintptr_t data); static const nxt_conn_state_t nxt_h1p_idle_state; static const nxt_conn_state_t nxt_h1p_proto_init_state; -static const nxt_conn_state_t nxt_h1p_request_init_state; static const nxt_conn_state_t nxt_h1p_header_parse_state; static const nxt_conn_state_t nxt_h1p_read_body_state; static const nxt_conn_state_t nxt_h1p_send_state; @@ -181,15 +179,13 @@ nxt_h1p_conn_read_header(nxt_task_t *task, void *obj, void *data) nxt_debug(task, "h1p conn read header"); - if (c->read == NULL) { - joint = c->joint; - size = joint->socket_conf->header_buffer_size; + joint = c->joint; + size = joint->socket_conf->header_buffer_size; - c->read = nxt_buf_mem_alloc(c->mem_pool, size, 0); - if (nxt_slow_path(c->read == NULL)) { - nxt_h1p_conn_error(task, c, c->socket.data); - return; - } + c->read = nxt_buf_mem_alloc(c->mem_pool, size, 0); + if (nxt_slow_path(c->read == NULL)) { + nxt_h1p_conn_error(task, c, c->socket.data); + return; } c->read_state = &nxt_h1p_proto_init_state; @@ -234,19 +230,6 @@ nxt_h1p_conn_proto_init(nxt_task_t *task, void *obj, void *data) } -static const nxt_conn_state_t nxt_h1p_request_init_state - nxt_aligned(64) = -{ - .ready_handler = nxt_h1p_conn_request_init, - .close_handler = nxt_h1p_conn_error, - .error_handler = nxt_h1p_conn_error, - - .timer_handler = nxt_h1p_conn_timeout, - .timer_value = nxt_h1p_conn_timeout_value, - .timer_data = offsetof(nxt_socket_conf_t, header_read_timeout), -}; - - static void nxt_h1p_conn_request_init(nxt_task_t *task, void *obj, void *data) { @@ -1041,14 +1024,9 @@ nxt_h1p_keepalive(nxt_task_t *task, nxt_h1proto_t *h1p, nxt_conn_t *c) in->mem.pos = in->mem.start; in->mem.free = in->mem.start; - if (c->socket.read_ready) { - c->read_state = &nxt_h1p_request_init_state; - nxt_conn_read(task->thread->engine, c); + c->read_state = &nxt_h1p_keepalive_state; - } else { - c->read_state = &nxt_h1p_keepalive_state; - nxt_conn_wait(c); - } + nxt_conn_read(task->thread->engine, c); } else { nxt_debug(task, "h1p pipelining"); @@ -1066,7 +1044,7 @@ nxt_h1p_keepalive(nxt_task_t *task, nxt_h1proto_t *h1p, nxt_conn_t *c) static const nxt_conn_state_t nxt_h1p_keepalive_state nxt_aligned(64) = { - .ready_handler = nxt_h1p_conn_keepalive, + .ready_handler = nxt_h1p_conn_request_init, .close_handler = nxt_h1p_conn_error, .error_handler = nxt_h1p_conn_error, @@ -1077,21 +1055,6 @@ static const nxt_conn_state_t nxt_h1p_keepalive_state static void -nxt_h1p_conn_keepalive(nxt_task_t *task, void *obj, void *data) -{ - nxt_conn_t *c; - - c = obj; - - nxt_debug(task, "h1p conn_keepalive"); - - c->read_state = &nxt_h1p_request_init_state; - - nxt_conn_read(task->thread->engine, c); -} - - -static void nxt_h1p_conn_error(nxt_task_t *task, void *obj, void *data) { nxt_conn_t *c; |