From 6439c70ee1ca10d2086c3721fe364800c27c00aa Mon Sep 17 00:00:00 2001 From: Evan Lin Date: Mon, 9 Sep 2019 02:50:28 +0800 Subject: [PATCH] Re-added initTransports for transport.Manager This was removed for some reason, but it needs to exist in order to reestablish transports on visor restart. --- pkg/transport/manager.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkg/transport/manager.go b/pkg/transport/manager.go index ccc246207a..3b2b1307eb 100644 --- a/pkg/transport/manager.go +++ b/pkg/transport/manager.go @@ -100,6 +100,8 @@ func (tm *Manager) serve(ctx context.Context) { } }() } + + tm.initTransports(ctx) tm.Logger.Info("transport manager is serving.") // closing logic @@ -116,6 +118,26 @@ func (tm *Manager) serve(ctx context.Context) { } } +func (tm *Manager) initTransports(ctx context.Context) { + tm.mx.Lock() + defer tm.mx.Unlock() + + entries, err := tm.conf.DiscoveryClient.GetTransportsByEdge(ctx, tm.conf.PubKey) + if err != nil { + log.Warnf("No transports found for local node: %v", err) + } + for _, entry := range entries { + var ( + tpType = entry.Entry.Type + remote = entry.Entry.RemoteEdge(tm.conf.PubKey) + tpID = entry.Entry.ID + ) + if _, err := tm.saveTransport(remote, tpType); err != nil { + tm.Logger.Warnf("INIT: failed to init tp: type(%s) remote(%s) tpID(%s)", tpType, remote, tpID) + } + } +} + func (tm *Manager) acceptTransport(ctx context.Context, lis *snet.Listener) error { conn, err := lis.AcceptConn() // TODO: tcp panic. if err != nil {