Skip to content

Commit

Permalink
Merge pull request #150 from julienschmidt/patch-1
Browse files Browse the repository at this point in the history
Check if channel is nil before updating it
  • Loading branch information
michaelklishin authored Feb 9, 2023
2 parents f9ba619 + 7bd1077 commit 30f5d55
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,13 +601,17 @@ func (c *Connection) dispatch0(f frame) {

func (c *Connection) dispatchN(f frame) {
c.m.Lock()
channel := c.channels[f.channel()]
updateChannel(f, channel)
channel, ok := c.channels[f.channel()]
if ok {
updateChannel(f, channel)
} else {
Logger.Printf("[debug] dropping frame, channel %d does not exist", f.channel())
}
c.m.Unlock()

// Note: this could result in concurrent dispatch depending on
// how channels are managed in an application
if channel != nil {
if ok {
channel.recv(channel, f)
} else {
c.dispatchClosed(f)
Expand Down

0 comments on commit 30f5d55

Please sign in to comment.