veyron/runtimes/google/ipc: Don't hold lock while calling Dial()
Change createFlow() to release the vcMap lock while calling Dial(). This
lock was effectively serializing RPCs to different servers.
Change-Id: I7b88c4ca87db8fa3e98703f31493af699417b911
diff --git a/runtimes/google/ipc/client.go b/runtimes/google/ipc/client.go
index 5782fe8..d20e598 100644
--- a/runtimes/google/ipc/client.go
+++ b/runtimes/google/ipc/client.go
@@ -86,11 +86,19 @@
// before removing the vc from the map?
delete(c.vcMap, ep.String())
}
+ c.vcMapMu.Unlock()
vc, err := c.streamMgr.Dial(ep, c.vcOpts...)
+ c.vcMapMu.Lock()
if err != nil {
return nil, err
}
- c.vcMap[ep.String()] = &vcInfo{vc: vc, remoteEP: ep}
+ if othervc, exists := c.vcMap[ep.String()]; exists {
+ vc = othervc.vc
+ // TODO(ashankar,toddw): Figure out how to close up the VC that
+ // is discarded. vc.Close?
+ } else {
+ c.vcMap[ep.String()] = &vcInfo{vc: vc, remoteEP: ep}
+ }
return vc.Connect()
}