Skip to content

Commit

Permalink
fix: Workaround some EOF errors on connections that closed gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
driskell committed Feb 26, 2024
1 parent 99bf67f commit 7d20247
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lc-lib/transports/tcp/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func newConnection(ctx context.Context, socket connectionSocket, protocolFactory

// Run starts the connection and all its routines
func (t *connection) run(startedCallback func()) error {
defer func () {
defer func() {
// Cleanup
t.socket.Close()

Expand Down Expand Up @@ -122,18 +122,20 @@ func (t *connection) run(startedCallback func()) error {
t.shutdownFunc()
}

// EOF is not an error to be returned
if err == io.EOF {
err = nil
}

// Wait for sender to complete due to Teardown or nil sent
t.wait.Wait()

// If we had no receiver error, did sender save one when it shutdown?
if err == nil {
return t.senderErr
err = t.senderErr
}

// EOF is not an error to be returned
// We check it here, after checking sender error, because with TLS an EOF can come from a send too
if err == io.EOF {
err = nil
}

return err
}

Expand Down

0 comments on commit 7d20247

Please sign in to comment.