Fix infinite hangs

This commit is contained in:
9seconds
2018-07-05 20:46:44 +03:00
parent 53ef81a4fc
commit 5413a5b090
5 changed files with 18 additions and 15 deletions
+3 -3
View File
@@ -28,6 +28,9 @@ type AbridgedReadWriteCloserWithAddr struct {
func (a *AbridgedReadWriteCloserWithAddr) Read(p []byte) (int, error) {
return a.BufferedRead(p, func() error {
a.opts.QuickAck = false
a.opts.SimpleAck = false
buf := &bytes.Buffer{}
buf.Grow(3)
@@ -37,7 +40,6 @@ func (a *AbridgedReadWriteCloserWithAddr) Read(p []byte) (int, error) {
msgLength := uint8(buf.Bytes()[0])
buf.Reset()
a.opts.QuickAck = false
if msgLength >= abridgedQuickAckLength {
a.opts.QuickAck = true
msgLength -= 0x80
@@ -78,13 +80,11 @@ func (a *AbridgedReadWriteCloserWithAddr) Write(p []byte) (int, error) {
case packetLength < abridgedLargePacketLength:
length24 := toUint24(uint32(packetLength))
buf := &bytes.Buffer{}
buf.Grow(1 + 3 + len(p))
buf.WriteByte(byte(abridgedSmallPacketLength))
buf.Write(length24[:])
buf.Write(p)
return a.conn.Write(buf.Bytes())
default: