Skip to content

Commit a743c7c

Browse files
committed
multi: add quit channel to sessionRpcServer
1 parent 140651a commit a743c7c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

session_rpcserver.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"strings"
7+
"sync"
78
"time"
89

910
"github.com/btcsuite/btcd/btcec"
@@ -20,6 +21,17 @@ type sessionRpcServer struct {
2021

2122
db *session.DB
2223
sessionServer *session.Server
24+
25+
quit chan struct{}
26+
27+
stopOnce sync.Once
28+
}
29+
30+
// stop cleans up any sessionRpcServer resources.
31+
func (s *sessionRpcServer) stop() {
32+
s.stopOnce.Do(func() {
33+
close(s.quit)
34+
})
2335
}
2436

2537
// AddSession adds and starts a new Terminal Connect session.

terminal.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ func (g *LightningTerminal) Run() error {
227227
basicAuth: g.rpcProxy.basicAuth,
228228
db: g.sessionDB,
229229
sessionServer: g.sessionServer,
230+
quit: make(chan struct{}),
230231
}
231232

232233
// Now start up all previously created sessions.
@@ -838,6 +839,7 @@ func (g *LightningTerminal) shutdown() error {
838839
}
839840
}
840841

842+
g.sessionRpcServer.stop()
841843
if err := g.sessionDB.Close(); err != nil {
842844
log.Errorf("Error closing session DB: %v", err)
843845
returnErr = err

0 commit comments

Comments
 (0)