Skip to content

Commit

Permalink
cln_plugin: always consider context done
Browse files Browse the repository at this point in the history
  • Loading branch information
JssDWt committed Apr 26, 2024
1 parent eadc22e commit 73d19ce
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cln_plugin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ func reusePort(network, address string, conn syscall.RawConn) error {
// Waits until the server has started, or errored during startup.
func (s *server) WaitStarted() error {
select {
case <-s.ctx.Done():
return s.ctx.Err()
case <-s.started:
return nil
case err := <-s.startError:
Expand Down Expand Up @@ -216,10 +218,13 @@ func (s *server) newHtlcStream(stream proto.ClnPlugin_HtlcStreamServer) error {

// Enqueues a htlc_accepted message for send to the grpc client.
func (s *server) SendHtlcAccepted(id string, h *HtlcAccepted) {
s.htlcSendQueue <- &htlcAcceptedMsg{
select {
case <-s.ctx.Done():
case s.htlcSendQueue <- &htlcAcceptedMsg{
id: id,
htlc: h,
timeout: time.Now().Add(s.subscriberTimeout),
}:
}
}

Expand Down Expand Up @@ -533,10 +538,13 @@ func (s *server) newCustomMsgStream(stream proto.ClnPlugin_CustomMsgStreamServer

// Enqueues a htlc_accepted message for send to the grpc client.
func (s *server) SendCustomMessage(id string, c *CustomMessageRequest) {
s.custommsgSendQueue <- &custommsgMsg{
select {
case <-s.ctx.Done():
case s.custommsgSendQueue <- &custommsgMsg{
id: id,
custommsg: c,
timeout: time.Now().Add(s.subscriberTimeout),
}:
}
}

Expand Down

0 comments on commit 73d19ce

Please sign in to comment.