Fixed timer and event race condition.

When idle timeout occurs at the same time as a request comes in,
the timer handler closes connection while the read event triggers
request processing, and this eventually leads to segmentation fault.
This commit is contained in:
Igor Sysoev
2019-02-28 18:04:11 +03:00
parent afda14d1f2
commit 834e8ca576
5 changed files with 17 additions and 8 deletions

View File

@@ -80,7 +80,8 @@ nxt_event_conn_job_sendfile_start(nxt_task_t *task, void *obj, void *data)
c->write = NULL;
jbs->ready_handler = nxt_event_conn_job_sendfile_return;
c->blocked = 1;
c->block_read = 1;
c->block_write = 1;
nxt_job_start(task, &jbs->job, nxt_event_conn_job_sendfile_handler);
return;
@@ -170,7 +171,8 @@ nxt_event_conn_job_sendfile_return(nxt_task_t *task, void *obj, void *data)
jbs = obj;
c = data;
c->blocked = 0;
c->block_read = 0;
c->block_write = 0;
sent = jbs->sent;
c->sent += sent;