Commit 1ccbb26f authored by suyanlong's avatar suyanlong

Fix newSidecar function return value

parent ebd26f9a
...@@ -160,6 +160,7 @@ func (swarm *Swarm) Start() error { ...@@ -160,6 +160,7 @@ func (swarm *Swarm) Start() error {
"node": remoteID, "node": remoteID,
"address:": address, "address:": address,
}).Info("Connect successfully") }).Info("Connect successfully")
{
//swarm.lock.RLock() //swarm.lock.RLock()
//defer swarm.lock.RUnlock() //defer swarm.lock.RUnlock()
//for _, handler := range swarm.connectHandlers { //for _, handler := range swarm.connectHandlers {
...@@ -167,6 +168,7 @@ func (swarm *Swarm) Start() error { ...@@ -167,6 +168,7 @@ func (swarm *Swarm) Start() error {
// connectHandler(address) // connectHandler(address)
// }(handler, address) // }(handler, address)
//} //}
}
wg.Done() wg.Done()
}(id, addr) }(id, addr)
} }
...@@ -198,7 +200,6 @@ func (swarm *Swarm) handleMessage(s network.Stream, data []byte) { ...@@ -198,7 +200,6 @@ func (swarm *Swarm) handleMessage(s network.Stream, data []byte) {
} }
msgHandlerPort, ok := handler.(MessageHandlerPort) msgHandlerPort, ok := handler.(MessageHandlerPort)
if ok { if ok {
msgHandlerPort(func() port.Port { return swarm.newSidecar(s.RemotePeerID()) }, m) msgHandlerPort(func() port.Port { return swarm.newSidecar(s.RemotePeerID()) }, m)
return return
} }
...@@ -212,6 +213,7 @@ func (swarm *Swarm) newSidecar(sidecarID string) *sidecar { ...@@ -212,6 +213,7 @@ func (swarm *Swarm) newSidecar(sidecarID string) *sidecar {
info, err := swarm.getRemotePeerInfo(sidecarID) info, err := swarm.getRemotePeerInfo(sidecarID)
if err != nil { if err != nil {
swarm.logger.Error(err) swarm.logger.Error(err)
return nil
} }
p := newSidecar(sidecarID, info.GetTag(), swarm) p := newSidecar(sidecarID, info.GetTag(), swarm)
return p return p
...@@ -228,9 +230,6 @@ func (swarm *Swarm) handleIBTPX(fn func() port.Port, m *pb.Message) { ...@@ -228,9 +230,6 @@ func (swarm *Swarm) handleIBTPX(fn func() port.Port, m *pb.Message) {
ps.Receive(m) ps.Receive(m)
} }
} else { } else {
//ppt := pt.(*sidecar)
//swarm.addRemotePort(ppt)
//ppt.Receive(m)
swarm.logger.WithFields(logrus.Fields{ swarm.logger.WithFields(logrus.Fields{
"remote port": pt.ID(), "remote port": pt.ID(),
"func": "Swarm.handleIBTPX", "func": "Swarm.handleIBTPX",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment