summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_thread.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2017-01-27 11:35:11 +0300
committerIgor Sysoev <igor@sysoev.ru>2017-01-27 11:35:11 +0300
commitba0391577b06446307fa073f856f57748557e0dd (patch)
treeb2b871a041edee242662c95197bed292531c3a9a /src/nxt_thread.c
parent6886b83c1f3bfdc514d58ad6e9ab40873cafcb54 (diff)
downloadunit-ba0391577b06446307fa073f856f57748557e0dd.tar.gz
unit-ba0391577b06446307fa073f856f57748557e0dd.tar.bz2
Work queues refactoring.
Diffstat (limited to '')
-rw-r--r--src/nxt_thread.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/nxt_thread.c b/src/nxt_thread.c
index 680412c2..24136bde 100644
--- a/src/nxt_thread.c
+++ b/src/nxt_thread.c
@@ -180,16 +180,22 @@ nxt_thread_time_cleanup(void *data)
void
nxt_thread_exit(nxt_thread_t *thr)
{
+ nxt_thread_link_t *link;
+
nxt_log_debug(thr->log, "thread exit");
- if (thr->link != NULL) {
- nxt_event_engine_post(thr->link->engine, thr->link->exit,
- &thr->link->engine->task,
- (void *) (uintptr_t) thr->handle,
- NULL, &nxt_main_log);
+ link = thr->link;
+ thr->link = NULL;
+
+ if (link != NULL) {
+ /*
+ * link->handler is already set to an exit handler,
+ * and link->task is already set to engine->task.
+ * The link should be freed by the exit handler.
+ */
+ link->work.obj = thr->handle;
- nxt_free(thr->link);
- thr->link = NULL;
+ nxt_event_engine_post(link->engine, &link->work);
}
nxt_thread_time_free(thr);