@cryptotaxi247 / kubo / commits / 900c1fbfa

net/id: when dup id, wait on it.

Juan Batiz-Benet committed Dec 24, 2014 at 03:38 UTC 900c1fbfa268265cabfeb685d512e14c58d21f26
1 file changed +3 -2
net/id.go
+3 -2
@@ -38,10 +38,11 @@ func NewIDService(n Network) *IDService {
38
39 func (ids *IDService) IdentifyConn(c Conn) {
40 ids.currmu.Lock()
41 - if _, found := ids.currid[c]; found {
41 + if wait, found := ids.currid[c]; found {
42 ids.currmu.Unlock()
43 log.Debugf("IdentifyConn called twice on: %s", c)
44 - return // already identifying it.
44 + <-wait // already identifying it. wait for it.
45 + return
46 }
47 ids.currid[c] = make(chan struct{})
48 ids.currmu.Unlock()