summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_port_memory.c
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2017-06-23 19:20:08 +0300
committerMax Romanov <max.romanov@nginx.com>2017-06-23 19:20:08 +0300
commit83088a0f4bdbe321c42e7cf0b18e2a9cc897b068 (patch)
tree97ef3d9e5d076f40ed6235d91d25f77921fa8af6 /src/nxt_port_memory.c
parentabe0d333294248ea654a4f8467d946a6b761b9d7 (diff)
downloadunit-83088a0f4bdbe321c42e7cf0b18e2a9cc897b068.tar.gz
unit-83088a0f4bdbe321c42e7cf0b18e2a9cc897b068.tar.bz2
Incoming and outgoing port_mmap arrays are protected with mutexes.
Diffstat (limited to 'src/nxt_port_memory.c')
-rw-r--r--src/nxt_port_memory.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/nxt_port_memory.c b/src/nxt_port_memory.c
index eabc2e2f..ba39c9c1 100644
--- a/src/nxt_port_memory.c
+++ b/src/nxt_port_memory.c
@@ -96,6 +96,8 @@ nxt_port_incoming_port_mmap(nxt_task_t *task, nxt_process_t *process,
return NULL;
}
+ nxt_thread_mutex_lock(&process->incoming_mutex);
+
if (process->incoming == NULL) {
process->incoming = nxt_array_create(process->mem_pool, 1,
sizeof(nxt_port_mmap_t));
@@ -135,6 +137,8 @@ nxt_port_incoming_port_mmap(nxt_task_t *task, nxt_process_t *process,
fail:
+ nxt_thread_mutex_unlock(&process->incoming_mutex);
+
return hdr;
}
@@ -309,6 +313,8 @@ nxt_port_mmap_get(nxt_task_t *task, nxt_port_t *port, nxt_chunk_id_t *c,
port_mmap = NULL;
hdr = NULL;
+ nxt_thread_mutex_lock(&process->outgoing_mutex);
+
if (process->outgoing == NULL) {
hdr = nxt_port_new_port_mmap(task, process, port);
@@ -336,6 +342,8 @@ nxt_port_mmap_get(nxt_task_t *task, nxt_port_t *port, nxt_chunk_id_t *c,
unlock_return:
+ nxt_thread_mutex_unlock(&process->outgoing_mutex);
+
return hdr;
}
@@ -355,6 +363,8 @@ nxt_port_get_port_incoming_mmap(nxt_task_t *task, nxt_pid_t spid, uint32_t id)
hdr = NULL;
+ nxt_thread_mutex_lock(&process->incoming_mutex);
+
incoming = process->incoming;
if (nxt_fast_path(incoming != NULL && incoming->nelts > id)) {
@@ -365,6 +375,8 @@ nxt_port_get_port_incoming_mmap(nxt_task_t *task, nxt_pid_t spid, uint32_t id)
"failed to get incoming mmap #%d for process %PI", id, spid);
}
+ nxt_thread_mutex_unlock(&process->incoming_mutex);
+
return hdr;
}