Handle errors from Close() in CheckUDPBufferSize
Added error handling for the Close() method calls in the CheckUDPBufferSize function to satisfy linting rules and improve error logging.
This commit is contained in:
parent
a6ae497c02
commit
7b473f60ae
@ -48,7 +48,11 @@ func CheckUDPBufferSize(wanted int) func(al *alerting.Alerting) {
|
|||||||
})
|
})
|
||||||
return
|
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)
|
udpConn, ok := conn.(*net.UDPConn)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -68,7 +72,11 @@ func CheckUDPBufferSize(wanted int) func(al *alerting.Alerting) {
|
|||||||
})
|
})
|
||||||
return
|
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)
|
size, err := syscall.GetsockoptInt(int(file.Fd()), syscall.SOL_SOCKET, syscall.SO_RCVBUF)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user