From c94e4e1de215983c12c6686877b281172eaf5355 Mon Sep 17 00:00:00 2001 From: Donald Adu-Poku Date: Tue, 26 Apr 2022 01:18:04 +0000 Subject: [PATCH] rpcserver: cleanup queueHandler process. This updates wsNotificationManager queueHandler to avoid checking if the channel is closed since it never is. The out label is also removed in favour of doing needed cleanup on context cancellation. --- internal/rpcserver/rpcwebsocket.go | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/internal/rpcserver/rpcwebsocket.go b/internal/rpcserver/rpcwebsocket.go index 3d2ccecced..b16d5d6e89 100644 --- a/internal/rpcserver/rpcwebsocket.go +++ b/internal/rpcserver/rpcwebsocket.go @@ -169,18 +169,15 @@ func (m *wsNotificationManager) queueHandler(ctx context.Context) { var dequeue chan<- interface{} skipQueue := m.notificationMsgs var next interface{} -out: + for { select { case <-ctx.Done(): - break out - - case n, ok := <-m.queueNotification: - if !ok { - // Sender closed input channel. - break out - } + close(m.notificationMsgs) + m.wg.Done() + return + case n := <-m.queueNotification: // Either send to out immediately if skipQueue is // non-nil (queue is empty) and reader is ready, // or append to the queue and send later. @@ -205,9 +202,6 @@ out: } } } - - close(m.notificationMsgs) - m.wg.Done() } // NotifyBlockConnected passes a block newly-connected to the best chain