conn.mux should always lookup session by RemoteChannel when a Begin is received
instead of only when lookup by Channel fails.
This commit is contained in:
Kale Blankenship 2018-02-07 21:26:49 -08:00
Родитель 5a703012fe
Коммит fa8dbbf18e
1 изменённых файлов: 17 добавлений и 12 удалений

29
conn.go
Просмотреть файл

@ -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
}
var (
session *Session
ok bool
)
session, ok = sessionsByChannel[begin.RemoteChannel]
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 {