diff --git a/pkg/netceptor/netceptor.go b/pkg/netceptor/netceptor.go index 483e5f0eb..f0eed31dc 100644 --- a/pkg/netceptor/netceptor.go +++ b/pkg/netceptor/netceptor.go @@ -356,6 +356,7 @@ func NewWithConsts(ctx context.Context, nodeID string, } s.AddNameHash(nodeID) s.context, s.cancelFunc = context.WithCancel(ctx) + defer s.cancelFunc() s.unreachableBroker = utils.NewBroker(s.context, reflect.TypeOf(UnreachableNotification{})) s.routingUpdateBroker = utils.NewBroker(s.context, reflect.TypeOf(map[string]string{})) s.updateRoutingTableChan = tickrunner.Run(s.context, s.updateRoutingTable, time.Hour*24, time.Millisecond*100) diff --git a/pkg/netceptor/packetconn.go b/pkg/netceptor/packetconn.go index c920dab3d..2156ff10d 100644 --- a/pkg/netceptor/packetconn.go +++ b/pkg/netceptor/packetconn.go @@ -139,6 +139,7 @@ func (pc *PacketConn) GetLogger() *logger.ReceptorLogger { // startUnreachable starts monitoring the netceptor unreachable channel and forwarding relevant messages. func (pc *PacketConn) StartUnreachable() { pc.context, pc.cancel = context.WithCancel(pc.s.Context()) + defer pc.cancel() pc.unreachableSubs = utils.NewBroker(pc.context, reflect.TypeOf(UnreachableNotification{})) iChan := pc.s.GetUnreachableBroker().Subscribe() go func() {