1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-30 01:52:26 +08:00

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

This commit is contained in:
Juan Batiz-Benet
2014-12-24 03:38:44 -08:00
parent ef0c25f463
commit 900c1fbfa2

View File

@ -38,10 +38,11 @@ func NewIDService(n Network) *IDService {
func (ids *IDService) IdentifyConn(c Conn) {
ids.currmu.Lock()
if _, found := ids.currid[c]; found {
if wait, found := ids.currid[c]; found {
ids.currmu.Unlock()
log.Debugf("IdentifyConn called twice on: %s", c)
return // already identifying it.
<-wait // already identifying it. wait for it.
return
}
ids.currid[c] = make(chan struct{})
ids.currmu.Unlock()