Преглед изворни кода

Drain any bad data from the conn

Armon Dadgar пре 10 година
родитељ
комит
bc7864bcf7
1 измењених фајлова са 7 додато и 0 уклоњено
  1. 7 0
      session.go

+ 7 - 0
session.go

@@ -4,6 +4,7 @@ import (
 	"bufio"
 	"fmt"
 	"io"
+	"io/ioutil"
 	"math"
 	"net"
 	"sync"
@@ -368,6 +369,12 @@ func (s *Session) handleStreamMessage(hdr header) error {
 
 	// If we do not have a stream, likely we sent a RST
 	if stream == nil {
+		// Drain any data on the wire
+		if hdr.MsgType() == typeData && hdr.Length() > 0 {
+			if _, err := io.CopyN(ioutil.Discard, s.bufRead, int64(hdr.Length())); err != nil {
+				return nil
+			}
+		}
 		return nil
 	}