From 3f5fdae284fdfcea1126202d6b81b53b00f032b3 Mon Sep 17 00:00:00 2001 From: Andy Wang Date: Wed, 22 Jan 2020 21:30:30 +0000 Subject: [PATCH] Close session immediately after receiving signal --- internal/multiplex/session.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/internal/multiplex/session.go b/internal/multiplex/session.go index 86e7ff0..47434ea 100644 --- a/internal/multiplex/session.go +++ b/internal/multiplex/session.go @@ -184,7 +184,7 @@ func (sesh *Session) recvDataFromRemote(data []byte) error { if frame.Closing == C_STREAM { streamI, existing := sesh.streams.Load(frame.StreamID) if existing { - // DO NOT close the stream (or session below) straight away here because the sequence number of this frame + // DO NOT close the stream straight away here because the sequence number of this frame // hasn't been checked. There may be later data frames which haven't arrived stream := streamI.(*Stream) return stream.writeFrame(*frame) @@ -193,15 +193,9 @@ func (sesh *Session) recvDataFromRemote(data []byte) error { return nil } } else if frame.Closing == C_SESSION { - streamI, existing := sesh.streams.Load(frame.StreamID) - if existing { - stream := streamI.(*Stream) - return stream.writeFrame(*frame) - } else { - // Closing session - sesh.SetTerminalMsg("Received a closing notification frame") - return sesh.passiveClose() - } + // Closing session + sesh.SetTerminalMsg("Received a closing notification frame") + return sesh.passiveClose() } else { connId, _, _ := sesh.sb.pickRandConn() // we ignore the error here. If the switchboard is broken, it will be reflected upon stream.Write