ctx.Done()

This commit is contained in:
chrislu
2025-09-13 21:29:27 -07:00
parent e501abcde6
commit 58eb40db01
2 changed files with 6 additions and 2 deletions
+2 -2
View File
@@ -146,9 +146,9 @@ func (s *Server) Close() error {
select {
case <-done:
// Normal shutdown
case <-time.After(2 * time.Second):
case <-time.After(1 * time.Second):
// Timeout - force shutdown
glog.Warningf("Server shutdown timed out after 2 seconds, forcing close")
glog.Warningf("Server shutdown timed out after 1 second, forcing close")
}
// Close the handler (important for SeaweedMQ mode)
+4
View File
@@ -324,6 +324,10 @@ func (h *Handler) HandleConn(ctx context.Context, conn net.Conn) error {
default:
// Already completed
}
case <-ctx.Done():
// Context cancelled, exit timeout goroutine
fmt.Printf("DEBUG: [%s] Force timeout goroutine cancelled due to context\n", connectionID)
return
case <-done:
// Operation completed, exit timeout goroutine
return