Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

Commit

Permalink
Fix conn.mux session lookup.
Browse files Browse the repository at this point in the history
conn.mux should always lookup session by RemoteChannel when a Begin is received
instead of only when lookup by Channel fails.
  • Loading branch information
vcabbage committed Feb 11, 2018
1 parent 5a70301 commit fa8dbbf
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,24 +314,29 @@ func (c *conn) mux() {

// new frame from connReader
case fr := <-c.rxFrame:
// lookup session and send to Session.mux
session, ok := sessionsByRemoteChannel[fr.channel]
if !ok {
// if this is a begin, RemoteChannel should be used
begin, ok := fr.body.(*performBegin)
if !ok {
c.err = errorErrorf("unexpected frame: %#v", fr.body)
continue
}

session, ok = sessionsByChannel[begin.RemoteChannel]
var (
session *Session
ok bool
)

switch body := fr.body.(type) {
// RemoteChannel should be used when frame is Begin
case *performBegin:
session, ok = sessionsByChannel[body.RemoteChannel]
if !ok {
c.err = errorErrorf("unexpected frame: %#v", fr.body)
continue
break
}

session.remoteChannel = fr.channel
sessionsByRemoteChannel[fr.channel] = session

default:
session, ok = sessionsByRemoteChannel[fr.channel]
}

if !ok {
c.err = errorErrorf("unexpected frame: %#v", fr.body)
continue
}

select {
Expand Down

0 comments on commit fa8dbbf

Please sign in to comment.