TUN-6691: Properly error check for net.ErrClosed
UDP session would check if the socket was closed before returning but the net.ErrClosed could be wrapped in another error.
This commit is contained in:
parent
59f5b0df83
commit
fc5749328d
datagramsession
|
@ -2,6 +2,7 @@ package datagramsession
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
|
@ -49,10 +50,10 @@ func (s *Session) Serve(ctx context.Context, closeAfterIdle time.Duration) (clos
|
|||
readBuffer := make([]byte, maxPacketSize)
|
||||
for {
|
||||
if closeSession, err := s.dstToTransport(readBuffer); err != nil {
|
||||
if err != net.ErrClosed {
|
||||
s.log.Error().Err(err).Msg("Failed to send session payload from destination to transport")
|
||||
if errors.Is(err, net.ErrClosed) {
|
||||
s.log.Debug().Msg("Destination connection closed")
|
||||
} else {
|
||||
s.log.Debug().Msg("Session cannot read from destination because the connection is closed")
|
||||
s.log.Error().Err(err).Msg("Failed to send session payload from destination to transport")
|
||||
}
|
||||
if closeSession {
|
||||
s.closeChan <- err
|
||||
|
|
Loading…
Reference in New Issue