From dea56448a1a892139d5750bce12ada2c2e1ad9be Mon Sep 17 00:00:00 2001 From: xtaci Date: Thu, 1 Sep 2016 14:11:53 +0800 Subject: [PATCH] reset peer when a SYN a opened stream --- session.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/session.go b/session.go index 3e154fb..285dc30 100644 --- a/session.go +++ b/session.go @@ -206,10 +206,14 @@ func (s *Session) recvLoop() { s.Close() return case cmdSYN: - chNotifyReader := make(chan struct{}, 1) - s.streams[f.sid] = newStream(f.sid, s.config.MaxFrameSize, chNotifyReader, s) - s.rdEvents[f.sid] = chNotifyReader - s.chAccepts <- s.streams[f.sid] + if _, ok := s.streams[f.sid]; !ok { + chNotifyReader := make(chan struct{}, 1) + s.streams[f.sid] = newStream(f.sid, s.config.MaxFrameSize, chNotifyReader, s) + s.rdEvents[f.sid] = chNotifyReader + s.chAccepts <- s.streams[f.sid] + } else { // stream exists, RST the peer + s.sendFrame(newFrame(cmdRST, f.sid)) + } s.tbf <- struct{}{} default: if _, ok := s.streams[f.sid]; ok {