From 5ab7617efd91c6aa95a61014354a3dca65bd3af6 Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Tue, 23 Feb 2021 09:27:03 -0500 Subject: [PATCH] server: Fix Shutdown with no active listeners Shutdown and Close will hang if there are no active listeners or connections. Try to close the done channel to avoid that. --- server.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server.go b/server.go index c98b8d7..7d86181 100644 --- a/server.go +++ b/server.go @@ -150,6 +150,8 @@ func (srv *Server) Shutdown(ctx context.Context) error { srv.closed = true srv.shutdown = true + srv.tryCloseDoneLocked() + // Close all active listeners. for _, cancel := range srv.listeners { cancel()