Skip to content

Commit

Permalink
Use map existence
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebakken committed Feb 8, 2023
1 parent 211fa78 commit 34f0302
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,15 +601,17 @@ func (c *Connection) dispatch0(f frame) {

func (c *Connection) dispatchN(f frame) {
c.m.Lock()
channel := c.channels[f.channel()]
if channel != nil {
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 34f0302

Please sign in to comment.