summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2017-07-18 00:21:17 +0300
committerMax Romanov <max.romanov@nginx.com>2017-07-18 00:21:17 +0300
commit8ad2c3fd3ad30982c4f777622c3392f047cc8191 (patch)
tree48cf79fd186b0c116223c78e9c8905c9f9085930 /src
parent803855138c3b714c088e42a32e80939a81785944 (diff)
downloadunit-8ad2c3fd3ad30982c4f777622c3392f047cc8191.tar.gz
unit-8ad2c3fd3ad30982c4f777622c3392f047cc8191.tar.bz2
Work queue thread assertions. Reset thread after fork.
Diffstat (limited to 'src')
-rw-r--r--src/nxt_event_engine.c16
-rw-r--r--src/nxt_event_engine.h10
-rw-r--r--src/nxt_process.c2
-rw-r--r--src/nxt_router.c2
-rw-r--r--src/nxt_work_queue.c20
-rw-r--r--src/nxt_work_queue.h7
6 files changed, 54 insertions, 3 deletions
diff --git a/src/nxt_event_engine.c b/src/nxt_event_engine.c
index b91f0e50..2ec7df1e 100644
--- a/src/nxt_event_engine.c
+++ b/src/nxt_event_engine.c
@@ -660,3 +660,19 @@ nxt_event_engine_request_find_remove(nxt_event_engine_t *engine,
return NULL;
}
+
+#if (NXT_DEBUG)
+
+void nxt_event_engine_thread_adopt(nxt_event_engine_t *engine)
+{
+ nxt_work_queue_thread_adopt(&engine->fast_work_queue);
+ nxt_work_queue_thread_adopt(&engine->accept_work_queue);
+ nxt_work_queue_thread_adopt(&engine->read_work_queue);
+ nxt_work_queue_thread_adopt(&engine->socket_work_queue);
+ nxt_work_queue_thread_adopt(&engine->connect_work_queue);
+ nxt_work_queue_thread_adopt(&engine->write_work_queue);
+ nxt_work_queue_thread_adopt(&engine->shutdown_work_queue);
+ nxt_work_queue_thread_adopt(&engine->close_work_queue);
+}
+
+#endif
diff --git a/src/nxt_event_engine.h b/src/nxt_event_engine.h
index d8741669..6c0adafd 100644
--- a/src/nxt_event_engine.h
+++ b/src/nxt_event_engine.h
@@ -531,5 +531,15 @@ nxt_thread_event_engine(void)
return thr->engine;
}
+#if (NXT_DEBUG)
+
+NXT_EXPORT void nxt_event_engine_thread_adopt(nxt_event_engine_t *engine);
+
+#else
+
+#define nxt_event_engine_thread_adopt(_engine)
+
+#endif
+
#endif /* _NXT_EVENT_ENGINE_H_INCLUDED_ */
diff --git a/src/nxt_process.c b/src/nxt_process.c
index 9561fb84..9ab3eaf3 100644
--- a/src/nxt_process.c
+++ b/src/nxt_process.c
@@ -50,6 +50,8 @@ nxt_process_create(nxt_task_t *task, nxt_process_t *process)
nxt_port_reset_next_id();
+ nxt_event_engine_thread_adopt(task->thread->engine);
+
/* Remove not ready processes */
nxt_runtime_process_each(rt, p) {
diff --git a/src/nxt_router.c b/src/nxt_router.c
index c103a861..77d2ad8d 100644
--- a/src/nxt_router.c
+++ b/src/nxt_router.c
@@ -1273,6 +1273,8 @@ nxt_router_thread_start(void *data)
thread = nxt_thread();
+ nxt_event_engine_thread_adopt(engine);
+
/* STUB */
thread->runtime = engine->task.thread->runtime;
diff --git a/src/nxt_work_queue.c b/src/nxt_work_queue.c
index 85f5cc3e..1b989eab 100644
--- a/src/nxt_work_queue.c
+++ b/src/nxt_work_queue.c
@@ -58,6 +58,26 @@ nxt_work_queue_thread_assert(nxt_work_queue_t *wq)
nxt_abort();
}
+
+void nxt_work_queue_thread_adopt(nxt_work_queue_t *wq)
+{
+ nxt_thread_t *thread;
+
+ thread = nxt_thread();
+
+ wq->pid = nxt_pid;
+ wq->tid = nxt_thread_tid(thread);
+}
+
+
+void
+nxt_work_queue_name(nxt_work_queue_t *wq, const char* name)
+{
+ nxt_work_queue_thread_assert(wq);
+
+ wq->name = name;
+}
+
#else
#define nxt_work_queue_thread_assert(wq)
diff --git a/src/nxt_work_queue.h b/src/nxt_work_queue.h
index 9819882e..9694bfd2 100644
--- a/src/nxt_work_queue.h
+++ b/src/nxt_work_queue.h
@@ -104,15 +104,16 @@ NXT_EXPORT nxt_work_handler_t nxt_work_queue_pop(nxt_work_queue_t *wq,
#if (NXT_DEBUG)
-#define \
-nxt_work_queue_name(_wq, _name) \
- (_wq)->name = _name
+NXT_EXPORT void nxt_work_queue_name(nxt_work_queue_t *wq, const char* name);
+NXT_EXPORT void nxt_work_queue_thread_adopt(nxt_work_queue_t *wq);
#else
#define \
nxt_work_queue_name(_wq, _name)
+#define nxt_work_queue_thread_adopt(_wq)
+
#endif