rpcserver: let sendPayment sendLoop listen for shutdown

Intead of checking for shutdown in the receive loop, we let the sendLoop
handle it, as it can return the error directly. This works since the
returning sendLoop will trigger a close of the `reqQuit` channel, which
will ensure the receive loop exits.
This commit is contained in:
Johan T. Halseth 2018-11-02 11:33:01 +01:00
parent ad0a89b844
commit f20f29696a
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

View File

@ -3696,9 +3696,7 @@ func (r *rpcServer) sendPayment(stream *paymentStream) error {
select {
case <-reqQuit:
return
case <-r.quit:
errChan <- nil
return
default:
// Receive the next pending payment within the
// stream sent by the client. If we read the
@ -3756,6 +3754,9 @@ func (r *rpcServer) sendPayment(stream *paymentStream) error {
case err := <-errChan:
return err
case <-r.quit:
return errors.New("rpc server shutting down")
case payIntent := <-payChan:
// We launch a new goroutine to execute the current
// payment so we can continue to serve requests while