From 02a58def2f35327a4bab99eacdd1392b0ccaa29c Mon Sep 17 00:00:00 2001 From: Jonathan Chappelow Date: Thu, 5 Aug 2021 11:38:53 -0700 Subject: [PATCH] rpcclient: Shutdown breaks reconnect sleep. When a shutdown is requested, the sleep should not continue in (*Client).wsReconnectHandler. Instead, use a select with the shutdown channel and a time.After. --- rpcclient/infrastructure.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rpcclient/infrastructure.go b/rpcclient/infrastructure.go index 593177cb..29a733ee 100644 --- a/rpcclient/infrastructure.go +++ b/rpcclient/infrastructure.go @@ -716,9 +716,13 @@ out: if scaledDuration > time.Minute { scaledDuration = time.Minute } - log.Infof("Retrying connection to %s in "+ - "%s", c.config.Host, scaledDuration) - time.Sleep(scaledDuration) + log.Infof("Retrying connection to %s in %s", + c.config.Host, scaledDuration) + select { + case <-c.shutdown: + break out + case <-time.After(scaledDuration): + } continue reconnect }