diff options
author | Max Romanov <max.romanov@nginx.com> | 2020-04-10 16:21:58 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2020-04-10 16:21:58 +0300 |
commit | 58cc13ab291cac5b13462006e3feb780178ef5f3 (patch) | |
tree | 0c52174f577f308b097922a1f5c8f14f86169355 /go | |
parent | c7f5c1c6641838006088524c2122eae8f9c30431 (diff) | |
download | unit-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.go | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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() } |