diff --git a/privval/signer_listener_endpoint.go b/privval/signer_listener_endpoint.go index 004ea1686..92464fa72 100644 --- a/privval/signer_listener_endpoint.go +++ b/privval/signer_listener_endpoint.go @@ -264,27 +264,30 @@ func (sl *SignerListenerEndpoint) serviceLoop() { select { case <-sl.connectCh: { - for { - sl.Logger.Info("Listening for new connection") - conn, err := sl.acceptNewConnection() - if err == nil { - sl.Logger.Info("Connected") - - select { - case sl.connectedCh <- conn: - { - sl.Logger.Debug("SignerListenerEndpoint: connection relayed") - } - case <-sl.stopCh: - { - sl.Logger.Debug("SignerListenerEndpoint: stopping") - return - } + sl.Logger.Info("Listening for new connection") + conn, err := sl.acceptNewConnection() + if err == nil { + sl.Logger.Info("Connected") + + // We have a good connection, wait for someone that needs one or cancellation + select { + case sl.connectedCh <- conn: + { + sl.Logger.Debug("SignerListenerEndpoint: connection relayed") + } + case <-sl.stopCh: + { + sl.Logger.Debug("SignerListenerEndpoint::serviceLoop Stop") + return } } } - } + select { + case sl.connectCh <- struct{}{}: + default: + } + } case <-sl.stopCh: { sl.Logger.Debug("SignerListenerEndpoint::serviceLoop Stop")