summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2019-08-16 14:55:18 +0300
committerMax Romanov <max.romanov@nginx.com>2019-08-16 14:55:18 +0300
commit686f5b1436a318135f288b563cb6e97fcdc9d8f8 (patch)
tree5225359ed232613c8ea37d91feec19d7cd45ee21
parent29911538ea91705fcdcbcf0e271cfbc5c8ed674b (diff)
downloadunit-686f5b1436a318135f288b563cb6e97fcdc9d8f8.tar.gz
unit-686f5b1436a318135f288b563cb6e97fcdc9d8f8.tar.bz2
Changing the sequence of body send execution.
Request state ready_handler required for further websocket events processing. It is not required for regular response transferring.
Diffstat (limited to '')
-rw-r--r--src/nxt_h1proto.c8
-rw-r--r--src/nxt_http_error.c6
-rw-r--r--src/nxt_router.c8
3 files changed, 11 insertions, 11 deletions
diff --git a/src/nxt_h1proto.c b/src/nxt_h1proto.c
index b0bd39e1..a92dfe3b 100644
--- a/src/nxt_h1proto.c
+++ b/src/nxt_h1proto.c
@@ -908,7 +908,6 @@ nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r)
nxt_h1proto_t *h1p;
const nxt_str_t *status;
nxt_http_field_t *field;
- nxt_event_engine_t *engine;
u_char buf[UNKNOWN_STATUS_LENGTH];
static const char chunked[] = "Transfer-Encoding: chunked\r\n";
@@ -1031,12 +1030,7 @@ nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r)
c->write = header;
c->write_state = &nxt_h1p_request_send_state;
- engine = task->thread->engine;
-
- nxt_work_queue_add(&engine->fast_work_queue, r->state->ready_handler,
- task, r, NULL);
-
- nxt_conn_write(engine, c);
+ nxt_conn_write(task->thread->engine, c);
}
diff --git a/src/nxt_http_error.c b/src/nxt_http_error.c
index 99d27903..c7c7e81a 100644
--- a/src/nxt_http_error.c
+++ b/src/nxt_http_error.c
@@ -51,9 +51,12 @@ nxt_http_request_error(nxt_task_t *task, nxt_http_request_t *r,
r->resp.content_length = NULL;
r->resp.content_length_n = nxt_length(error);
+ nxt_http_request_header_send(task, r);
+
r->state = &nxt_http_request_send_error_body_state;
- nxt_http_request_header_send(task, r);
+ nxt_work_queue_add(&task->thread->engine->fast_work_queue,
+ nxt_http_request_send_error_body, task, r, NULL);
return;
fail:
@@ -65,7 +68,6 @@ fail:
static const nxt_http_request_state_t nxt_http_request_send_error_body_state
nxt_aligned(64) =
{
- .ready_handler = nxt_http_request_send_error_body,
.error_handler = nxt_http_request_error_handler,
};
diff --git a/src/nxt_router.c b/src/nxt_router.c
index 509f487a..566e0c65 100644
--- a/src/nxt_router.c
+++ b/src/nxt_router.c
@@ -3540,9 +3540,14 @@ nxt_router_response_ready_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg,
nxt_buf_chain_add(&r->out, b);
}
+ nxt_http_request_header_send(task, r);
+
r->state = &nxt_http_request_send_state;
- nxt_http_request_header_send(task, r);
+ if (r->out) {
+ nxt_work_queue_add(&task->thread->engine->fast_work_queue,
+ nxt_http_request_send_body, task, r, NULL);
+ }
}
return;
@@ -3558,7 +3563,6 @@ fail:
static const nxt_http_request_state_t nxt_http_request_send_state
nxt_aligned(64) =
{
- .ready_handler = nxt_http_request_send_body,
.error_handler = nxt_http_request_error_handler,
};