summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conn_write.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2018-07-12 18:29:22 +0300
committerIgor Sysoev <igor@sysoev.ru>2018-07-12 18:29:22 +0300
commitbd8eacf52d22c37b2ca7e757a618aec0119467f7 (patch)
tree0034aa1cb8eaaa09f90760d5b16f1d54d0744cfe /src/nxt_conn_write.c
parent5de582f6db1b005fad90e4c2895624cc09c25797 (diff)
downloadunit-bd8eacf52d22c37b2ca7e757a618aec0119467f7.tar.gz
unit-bd8eacf52d22c37b2ca7e757a618aec0119467f7.tar.bz2
Fixed socket write error handling.
Diffstat (limited to 'src/nxt_conn_write.c')
-rw-r--r--src/nxt_conn_write.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/nxt_conn_write.c b/src/nxt_conn_write.c
index f40f9c2f..ac73bb9e 100644
--- a/src/nxt_conn_write.c
+++ b/src/nxt_conn_write.c
@@ -24,6 +24,10 @@ nxt_conn_io_write(nxt_task_t *task, void *obj, void *data)
nxt_debug(task, "conn write fd:%d", c->socket.fd);
+ if (c->socket.error != 0) {
+ goto error;
+ }
+
if (!c->socket.write_ready || c->write == NULL) {
return;
}
@@ -109,22 +113,25 @@ nxt_conn_io_write(nxt_task_t *task, void *obj, void *data)
}
if (ret == 0 || sb.sent != 0) {
- /* "ret == 0" means a sync buffer was processed. */
+ /*
+ * ret == 0 means a sync buffer was processed.
+ * ret == NXT_ERROR is ignored here if some data was sent,
+ * the error will be handled on the next nxt_conn_write() call.
+ */
c->sent += sb.sent;
nxt_work_queue_add(c->write_work_queue, c->write_state->ready_handler,
task, c, data);
- /*
- * Fall through if first operations were
- * successful but the last one failed.
- */
+ return;
}
- if (nxt_slow_path(ret == NXT_ERROR)) {
- nxt_fd_event_block_write(engine, &c->socket);
+ /* ret == NXT_ERROR */
- nxt_work_queue_add(c->write_work_queue, c->write_state->error_handler,
- task, c, data);
- }
+ nxt_fd_event_block_write(engine, &c->socket);
+
+error:
+
+ nxt_work_queue_add(c->write_work_queue, c->write_state->error_handler,
+ task, c, data);
}