From 4a2642e54da31a59beb1e02c8ee47e4f270a9893 Mon Sep 17 00:00:00 2001 From: chrislu Date: Sat, 13 Sep 2025 21:20:54 -0700 Subject: [PATCH] more timeout --- weed/mq/kafka/protocol/handler.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/weed/mq/kafka/protocol/handler.go b/weed/mq/kafka/protocol/handler.go index a1d038701..2fe3b5f50 100644 --- a/weed/mq/kafka/protocol/handler.go +++ b/weed/mq/kafka/protocol/handler.go @@ -307,13 +307,18 @@ func (h *Handler) HandleConn(ctx context.Context, conn net.Conn) error { // Start a timeout goroutine that will force completion after 1 second go func() { - time.Sleep(1 * time.Second) select { - case done <- true: - fmt.Printf("DEBUG: [%s] Force timeout after 1 second, closing connection\n", connectionID) - finalErr = fmt.Errorf("force timeout") - default: - // Already completed + case <-time.After(1 * time.Second): + select { + case done <- true: + fmt.Printf("DEBUG: [%s] Force timeout after 1 second, closing connection\n", connectionID) + finalErr = fmt.Errorf("force timeout") + default: + // Already completed + } + case <-done: + // Operation completed, exit timeout goroutine + return } }()