From 7ecd477545b27f2abdf14932ca1a57f65211316e Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Thu, 30 Apr 2020 10:40:07 +0100 Subject: [PATCH] Prevent initialization deadlock bug If the server was signaled to shutdown when the Node was still waiting to read its configuration, the configReady channel would never fire, causing a lockup in NewNode(). --- node/node.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/node/node.go b/node/node.go index a0071a9b..b73767f3 100644 --- a/node/node.go +++ b/node/node.go @@ -96,7 +96,11 @@ func New(parentCtx context.Context, session *concurrency.Session, ice Icecast, n n.updateIcecast() } }() - <-configReady + select { + case <-ctx.Done(): + return nil, ctx.Err() + case <-configReady: + } // Register the Icecast endpoints. First the gossip service, below // StatusEndpointPrefix with gossipPort, then the public Icecast -- GitLab