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
|
||||
}
|
||||
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 {
|
||||
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user