Skip to content

Commit

Permalink
Close server hbConn on err
Browse files Browse the repository at this point in the history
Since all err on c.stream Read represents some issue with the underlying conn, it should be safe to close the connection upon receiving an error.
  • Loading branch information
mingyech committed Feb 5, 2024
1 parent eb36f06 commit a757b05
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions pkg/dtls/heartbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package dtls
import (
"bytes"
"errors"
"io"
"net"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -84,13 +82,8 @@ func (c *hbConn) recvLoop() {
}

if err != nil {
c.recvCh <- errBytes{nil, err}
switch {
case errors.Is(err, net.ErrClosed):
case errors.Is(err, io.EOF):
c.Close()
return
}
c.Close()
return
}

c.recvCh <- errBytes{buffer[:n], err}
Expand Down

0 comments on commit a757b05

Please sign in to comment.