Skip to content

Commit

Permalink
Merge pull request #132 from bookingcom/grzkv/fix_udp_closed_conn_check
Browse files Browse the repository at this point in the history
Added proper closed connection error type check for UDP.
  • Loading branch information
grzkv authored Jun 18, 2021
2 parents 92935d3 + 1a4576e commit 7ce7e50
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pkg/in/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package in

import (
"bytes"
"errors"
"net"
"strings"
"sync"

"github.com/bookingcom/nanotube/pkg/metrics"
Expand All @@ -24,8 +24,7 @@ func listenUDP(conn net.PacketConn, queue chan string, stop <-chan struct{}, con
for {
nRead, _, err := conn.ReadFrom(buf)
if err != nil {
// There is no other way, see https://github.com/golang/go/issues/4373
if strings.Contains(err.Error(), "use of closed network connection") {
if errors.Is(err, net.ErrClosed) {
break
}

Expand Down

0 comments on commit 7ce7e50

Please sign in to comment.