Compare commits

...

4 Commits
main ... v1.1.2

Author SHA1 Message Date
Derek McGowan 20c493e601
Merge pull request #143 from dmcgowan/backport-1.1-error-unwrap
[release/1.1] Unwrap io errors in server connection receive error handling
2023-05-17 16:15:10 -07:00
Austin Vazquez d5f7eeddb5 Unwrap io errors in server connection receive error handling
Unwrap io.EOF and io.ErrUnexpectedEOF in the case of read message error
which would lead to leaked server connections.

Signed-off-by: Austin Vazquez <macedonv@amazon.com>
(cherry picked from commit 9599fadcd6)
Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-05-08 16:46:27 -07:00
Fu Wei e1f0dab5fd
Merge pull request #136 from dmcgowan/backport-reset-leak 2023-03-24 23:19:31 +08:00
liyuxuan.darfux 8977f59dbd server: Fix connection leak when receiving ECONNRESET
The ttrpc server somtimes receives `ECONNRESET` rather than `EOF` when
the client is exited. Such as reading from a closed connection. Handle
it properly to avoid goroutine and connection leak.

Change-Id: If32711cfc1347dd2da27ca846dd13c3f5af351bb
Signed-off-by: liyuxuan.darfux <liyuxuan.darfux@bytedance.com>
(cherry picked from commit a03aa04591)
Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-03-23 17:22:34 -07:00
1 changed files with 3 additions and 4 deletions

View File

@ -24,6 +24,7 @@ import (
"net"
"sync"
"sync/atomic"
"syscall"
"time"
"github.com/sirupsen/logrus"
@ -467,14 +468,12 @@ func (c *serverConn) run(sctx context.Context) {
// branch. Basically, it means that we are no longer receiving
// requests due to a terminal error.
recvErr = nil // connection is now "closing"
if err == io.EOF || err == io.ErrUnexpectedEOF {
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, syscall.ECONNRESET) {
// The client went away and we should stop processing
// requests, so that the client connection is closed
return
}
if err != nil {
logrus.WithError(err).Error("error receiving message")
}
logrus.WithError(err).Error("error receiving message")
case <-shutdown:
return
}