fix hang on exit

This commit is contained in:
Ryan Huber
2025-10-31 13:50:52 -04:00
parent 51b383f680
commit 68746bd907

View File

@@ -1354,6 +1354,13 @@ func (u *StdConn) getMemInfo(meminfo *[unix.SK_MEMINFO_VARS]uint32) error {
}
func (u *StdConn) Close() error {
// Attempt to unblock any outstanding sendmsg/sendmmsg calls so the shard
// workers can drain promptly during shutdown. Ignoring errors here is fine
// because some platforms/kernels may not support shutdown on UDP sockets.
if err := unix.Shutdown(u.sysFd, unix.SHUT_WR); err != nil && err != unix.ENOTCONN && err != unix.EINVAL && err != unix.EBADF {
u.l.WithError(err).Debug("Failed to shutdown UDP socket for close")
}
var flushErr error
for _, shard := range u.sendShards {
if shard == nil {