summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_process.c
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2020-04-10 16:21:58 +0300
committerMax Romanov <max.romanov@nginx.com>2020-04-10 16:21:58 +0300
commit58cc13ab291cac5b13462006e3feb780178ef5f3 (patch)
tree0c52174f577f308b097922a1f5c8f14f86169355 /src/nxt_process.c
parentc7f5c1c6641838006088524c2122eae8f9c30431 (diff)
downloadunit-58cc13ab291cac5b13462006e3feb780178ef5f3.tar.gz
unit-58cc13ab291cac5b13462006e3feb780178ef5f3.tar.bz2
Resolving a racing condition while adding ports on the app's side.
An earlier attempt (ad6265786871) to resolve this condition on the router's side added a new issue: the app could get a request before acquiring a port.
Diffstat (limited to 'src/nxt_process.c')
-rw-r--r--src/nxt_process.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/nxt_process.c b/src/nxt_process.c
index 4179844b..f5959edf 100644
--- a/src/nxt_process.c
+++ b/src/nxt_process.c
@@ -591,6 +591,17 @@ nxt_process_close_ports(nxt_task_t *task, nxt_process_t *process)
void
+nxt_process_connected_port_add(nxt_process_t *process, nxt_port_t *port)
+{
+ nxt_thread_mutex_lock(&process->cp_mutex);
+
+ nxt_port_hash_add(&process->connected_ports, port);
+
+ nxt_thread_mutex_unlock(&process->cp_mutex);
+}
+
+
+void
nxt_process_connected_port_remove(nxt_process_t *process, nxt_port_t *port)
{
nxt_thread_mutex_lock(&process->cp_mutex);
@@ -602,7 +613,7 @@ nxt_process_connected_port_remove(nxt_process_t *process, nxt_port_t *port)
nxt_port_t *
-nxt_process_connected_port_find_add(nxt_process_t *process, nxt_port_t *port)
+nxt_process_connected_port_find(nxt_process_t *process, nxt_port_t *port)
{
nxt_port_t *res;
@@ -610,10 +621,6 @@ nxt_process_connected_port_find_add(nxt_process_t *process, nxt_port_t *port)
res = nxt_port_hash_find(&process->connected_ports, port->pid, port->id);
- if (nxt_slow_path(res == NULL)) {
- nxt_port_hash_add(&process->connected_ports, port);
- }
-
nxt_thread_mutex_unlock(&process->cp_mutex);
return res;