Skip to content

Commit

Permalink
Handle errors from Close() in CheckUDPBufferSize
Browse files Browse the repository at this point in the history
Added error handling for the Close() method calls in the CheckUDPBufferSize function to satisfy linting rules and improve error logging.
  • Loading branch information
rjan90 committed Oct 30, 2023
1 parent a6ae497 commit 7b473f6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions node/modules/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ func CheckUDPBufferSize(wanted int) func(al *alerting.Alerting) {
})
return
}
defer conn.Close()
defer func() {
if err := conn.Close(); err != nil {
log.Warnf("Failed to close connection: %s", err)
}
}()

udpConn, ok := conn.(*net.UDPConn)
if !ok {
Expand All @@ -68,7 +72,11 @@ func CheckUDPBufferSize(wanted int) func(al *alerting.Alerting) {
})
return
}
defer file.Close()
defer func() {
if err := file.Close(); err != nil {
log.Warnf("Failed to close file: %s", err)
}
}()

size, err := syscall.GetsockoptInt(int(file.Fd()), syscall.SOL_SOCKET, syscall.SO_RCVBUF)
if err != nil {
Expand Down

0 comments on commit 7b473f6

Please sign in to comment.