Skip to content

Commit 15c2959

Browse files
committed
Fix preConnectionCopy
1 parent a06a0b5 commit 15c2959

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

route/conn.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func (m *ConnectionManager) preConnectionCopy(ctx context.Context, source net.Co
235235
err = m.connectionCopyEarlyWrite(source, destination, readHandshake, writeHandshake)
236236
if err == nil && N.NeedHandshakeForRead(source) {
237237
continue
238-
} else if err == os.ErrInvalid || err == context.DeadlineExceeded {
238+
} else if E.IsMulti(err, os.ErrInvalid, context.DeadlineExceeded, io.EOF) {
239239
err = nil
240240
}
241241
break
@@ -340,10 +340,19 @@ func (m *ConnectionManager) connectionCopyEarlyWrite(source net.Conn, destinatio
340340
}
341341
return err
342342
}
343+
var (
344+
isTimeout bool
345+
isEOF bool
346+
)
343347
_, err = payload.ReadOnceFrom(source)
344-
isTimeout := E.IsTimeout(err)
345-
if err != nil && !(isTimeout || errors.Is(err, io.EOF)) {
346-
return E.Cause(err, "read payload")
348+
if err != nil {
349+
if E.IsTimeout(err) {
350+
isTimeout = true
351+
} else if errors.Is(err, io.EOF) {
352+
isEOF = true
353+
} else {
354+
return E.Cause(err, "read payload")
355+
}
347356
}
348357
_ = source.SetReadDeadline(time.Time{})
349358
if !payload.IsEmpty() || writeHandshake {
@@ -354,6 +363,8 @@ func (m *ConnectionManager) connectionCopyEarlyWrite(source net.Conn, destinatio
354363
}
355364
if isTimeout {
356365
return context.DeadlineExceeded
366+
} else if isEOF {
367+
return io.EOF
357368
}
358369
return nil
359370
}

0 commit comments

Comments
 (0)