Commit 0e75ebad authored by Adam Rice's avatar Adam Rice Committed by Chromium LUCI CQ

Shutdown UDP sockets before close on Mac OS

On Big Sur, guarded_close_np() has started sometimes returning
EPROTOTYPE or ENOTCONN errors. Try calling shutdown() before close as
a speculative workaround.

BUG=1151048

Change-Id: I99e4a58f1468027402099fd5b0220872f14b1578
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2561079Reviewed-by: default avatarDavid Schinazi <dschinazi@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833429}
parent 7daf8c22
...@@ -292,6 +292,11 @@ void UDPSocketPosix::Close() { ...@@ -292,6 +292,11 @@ void UDPSocketPosix::Close() {
// crbug.com/906005. // crbug.com/906005.
CHECK_EQ(socket_hash_, GetSocketFDHash(socket_)); CHECK_EQ(socket_hash_, GetSocketFDHash(socket_));
#if defined(OS_MAC) #if defined(OS_MAC)
// This is a speculative workaround for https://crbug.com/1151048. The idea is
// that the call to shutdown() will absorb any errors on the socket, so they
// won't be reported by close.
// TODO(ricea): Remove if this if it doesn't work or a proper fix is found.
HANDLE_EINTR(shutdown(socket_, SHUT_RDWR));
PCHECK(IGNORE_EINTR(guarded_close_np(socket_, &kSocketFdGuard)) == 0); PCHECK(IGNORE_EINTR(guarded_close_np(socket_, &kSocketFdGuard)) == 0);
#else #else
PCHECK(IGNORE_EINTR(close(socket_)) == 0); PCHECK(IGNORE_EINTR(close(socket_)) == 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment