Skip to content

Commit

Permalink
peer: panic early on queued nil messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed Nov 13, 2023
1 parent c077ac8 commit 5f2c394
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,14 @@ cleanup:
//
// This function is safe for concurrent access.
func (p *Peer) QueueMessage(msg wire.Message, doneChan chan<- struct{}) {
// Panic early on nil messages. This provides a more useful stack
// trace to callers than hitting the panic in a long-lived peer
// goroutine that contains no information about what caller queued the
// nil message.
if msg == nil {
panic("peer: nil message")
}

// Avoid risk of deadlock if goroutine already exited. The goroutine
// we will be sending to hangs around until it knows for a fact that
// it is marked as disconnected and *then* it drains the channels.
Expand Down

0 comments on commit 5f2c394

Please sign in to comment.