Skip to content

Commit 10048ce

Browse files
committed
fix: add return when receive unexpected error
1 parent 9638fba commit 10048ce

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

server.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ func (s *Server) Serve(ctx context.Context, l net.Listener) error {
113113
backoff *= 2
114114
}
115115

116-
backoff = min(time.Second, backoff)
116+
if max := time.Second; backoff > max {
117+
backoff = max
118+
}
117119

118120
sleep := time.Duration(rand.Int63n(int64(backoff)))
119121
log.G(ctx).WithError(err).Errorf("ttrpc: failed accept; backoff %v", sleep)
@@ -558,7 +560,7 @@ func (c *serverConn) run(sctx context.Context) {
558560
return
559561
}
560562
log.G(ctx).WithError(err).Error("error receiving message")
561-
// else, initiate shutdown
563+
return
562564
case <-shutdown:
563565
return
564566
}

0 commit comments

Comments
 (0)