Skip to content

Commit

Permalink
Improve logging and route group closing procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Jan 28, 2020
1 parent 36a8e60 commit 13add47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 4 additions & 9 deletions pkg/router/route_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ func (rg *RouteGroup) sendKeepAlive() error {

packet := routing.MakeKeepAlivePacket(rule.KeyRouteID())
if err := tp.WritePacket(context.Background(), packet); err != nil {
rg.logger.WithError(err).Error("Failed to send keep-alive packet")
return err
}

Expand All @@ -380,10 +381,7 @@ func (rg *RouteGroup) close(code routing.CloseCode) error {
rg.closeDone.Add(len(rg.tps))
}

if err := rg.broadcastClosePackets(code); err != nil {
// TODO: decide if we should return this error, or close route group anyway
return err
}
rg.broadcastClosePackets(code)

if closeInitiator {
// if this node initiated closing, we need to wait for close packets
Expand Down Expand Up @@ -430,16 +428,13 @@ func (rg *RouteGroup) handleClosePacket(code routing.CloseCode) error {
return rg.close(code)
}

func (rg *RouteGroup) broadcastClosePackets(code routing.CloseCode) error {
func (rg *RouteGroup) broadcastClosePackets(code routing.CloseCode) {
for i := 0; i < len(rg.tps); i++ {
packet := routing.MakeClosePacket(rg.fwd[i].KeyRouteID(), code)
if err := rg.tps[i].WritePacket(context.Background(), packet); err != nil {
// TODO: decide if we should return this error, or close route group anyway
return err
rg.logger.WithError(err).Error("Failed to send close packet")
}
}

return nil
}

func (rg *RouteGroup) waitForCloseLoop(waitTimeout time.Duration) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/transport/managed_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (mt *ManagedTransport) Serve(readCh chan<- routing.Packet, done <-chan stru
mt.connMx.Lock()
if mt.conn == nil {
if err := mt.dial(ctx); err != nil {
mt.log.Warnf("failed to redial underlying connection: %v", err)
mt.log.Warnf("failed to redial underlying connection (redial loop): %v", err)
}
}
mt.connMx.Unlock()
Expand Down

0 comments on commit 13add47

Please sign in to comment.