summaryrefslogtreecommitdiffhomepage
path: root/go
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 /go
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 'go')
-rw-r--r--go/port.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/go/port.go b/go/port.go
index 72d33d31..59a13f8b 100644
--- a/go/port.go
+++ b/go/port.go
@@ -50,7 +50,11 @@ func add_port(p *port) {
port_registry_.m = make(map[port_key]*port)
}
- port_registry_.m[p.key] = p
+ old := port_registry_.m[p.key]
+
+ if old == nil {
+ port_registry_.m[p.key] = p
+ }
port_registry_.Unlock()
}