summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_router.c
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2020-12-17 19:27:44 +0300
committerMax Romanov <max.romanov@nginx.com>2020-12-17 19:27:44 +0300
commitc0449e13f80312a2e09f643e1a69e536384eae79 (patch)
treeeca86fb8fa3e0f185f9308b111edf0de81ab4ccb /src/nxt_router.c
parent53d847615b270daf706373d65ac5f5d2101f36d9 (diff)
downloadunit-c0449e13f80312a2e09f643e1a69e536384eae79.tar.gz
unit-c0449e13f80312a2e09f643e1a69e536384eae79.tar.bz2
Router: fixed crash in OOSM processing.
Multithreaded application may create different shared memory segments in different threads. The segments then passed to different router threads. Because of this multithreading, the order of adding incoming segments is not determined and there can be situation when some of the incoming segments are not initialized yet. This patch simply adds check for NULL to skip non-initialized segments. Crash reproduced during load tests with high number of simultaneous connections (1024 and more).
Diffstat (limited to 'src/nxt_router.c')
-rw-r--r--src/nxt_router.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/nxt_router.c b/src/nxt_router.c
index 871602e4..0416dea0 100644
--- a/src/nxt_router.c
+++ b/src/nxt_router.c
@@ -5373,7 +5373,7 @@ nxt_router_oosm_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
nxt_bool_t ack;
nxt_process_t *process;
nxt_free_map_t *m;
- nxt_port_mmap_header_t *hdr;
+ nxt_port_mmap_handler_t *mmap_handler;
nxt_debug(task, "oosm in %PI", msg->port_msg.pid);
@@ -5394,8 +5394,13 @@ nxt_router_oosm_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
nxt_thread_mutex_lock(&process->incoming.mutex);
for (i = 0; i < process->incoming.size; i++) {
- hdr = process->incoming.elts[i].mmap_handler->hdr;
- m = hdr->free_map;
+ mmap_handler = process->incoming.elts[i].mmap_handler;
+
+ if (nxt_slow_path(mmap_handler == NULL)) {
+ continue;
+ }
+
+ m = mmap_handler->hdr->free_map;
for (mi = 0; mi < MAX_FREE_IDX; mi++) {
if (m[mi] != 0) {