From 8fba3eb72951dfe0c8955a76c91684ec21699ca7 Mon Sep 17 00:00:00 2001 From: Chandra Thumuluru Date: Fri, 19 Sep 2025 19:47:36 +0000 Subject: [PATCH] rpc: avoid closing already closed DRPC connection Previously, closing an already closed DRPC connection would lead to a panic. `panic: close of closed channel` This patch makes the closing of an already closed connection to be a no-op. Epic: none Release note: None --- pkg/rpc/drpc.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/rpc/drpc.go b/pkg/rpc/drpc.go index 48e15ca622cf..ac608894a881 100644 --- a/pkg/rpc/drpc.go +++ b/pkg/rpc/drpc.go @@ -138,8 +138,13 @@ type closeEntirePoolConn struct { } func (c *closeEntirePoolConn) Close() error { - _ = c.Conn.Close() - return c.pool.Close() + select { + case <-c.Conn.Closed(): + return nil // already closed + default: + _ = c.Conn.Close() + return c.pool.Close() + } } type DRPCConnection = Connection[drpc.Conn]