multi: add quit channel to sessionRpcServer

This commit is contained in:
Elle Mouton 2022-01-07 13:50:27 +02:00
parent 140651adcd
commit a743c7cb1e
2 changed files with 14 additions and 0 deletions

View file

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"strings"
"sync"
"time"
"github.com/btcsuite/btcd/btcec"
@ -20,6 +21,17 @@ type sessionRpcServer struct {
db *session.DB
sessionServer *session.Server
quit chan struct{}
stopOnce sync.Once
}
// stop cleans up any sessionRpcServer resources.
func (s *sessionRpcServer) stop() {
s.stopOnce.Do(func() {
close(s.quit)
})
}
// AddSession adds and starts a new Terminal Connect session.

View file

@ -227,6 +227,7 @@ func (g *LightningTerminal) Run() error {
basicAuth: g.rpcProxy.basicAuth,
db: g.sessionDB,
sessionServer: g.sessionServer,
quit: make(chan struct{}),
}
// Now start up all previously created sessions.
@ -838,6 +839,7 @@ func (g *LightningTerminal) shutdown() error {
}
}
g.sessionRpcServer.stop()
if err := g.sessionDB.Close(); err != nil {
log.Errorf("Error closing session DB: %v", err)
returnErr = err