mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-02 17:08:34 +02:00
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:
parent
ad0a89b844
commit
f20f29696a
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user