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.
This commit is contained in:
Max Romanov
2020-04-10 16:21:58 +03:00
parent c7f5c1c664
commit 58cc13ab29
5 changed files with 48 additions and 13 deletions

View File

@@ -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()
}