Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Unified Diff: net/socket/socket_descriptor.cc

Issue 2034433002: Try to tolerate running on contexts with SIGPIPE enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/socket/socket_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/socket_descriptor.cc
diff --git a/net/socket/socket_descriptor.cc b/net/socket/socket_descriptor.cc
index b10f2dcb41d6b682d48b9c63d5a3c9d3cec88e54..5e9623c52389495b259cb22459ccebc24a864821 100644
--- a/net/socket/socket_descriptor.cc
+++ b/net/socket/socket_descriptor.cc
@@ -14,6 +14,10 @@
#include "net/base/winsock_init.h"
#endif
+#if defined(OS_MACOSX)
+#include <unistd.h>
+#endif
+
namespace net {
SocketDescriptor CreatePlatformSocket(int family, int type, int protocol) {
@@ -31,7 +35,20 @@ SocketDescriptor CreatePlatformSocket(int family, int type, int protocol) {
}
return result;
#else // OS_WIN
- return ::socket(family, type, protocol);
+ SocketDescriptor result = ::socket(family, type, protocol);
+#if defined(OS_MACOSX)
+ // Disable SIGPIPE on this socket. Although Chromium globally disables
+ // SIGPIPE, the net stack may be used in other consumers which do not do
+ // this. SO_NOSIGPIPE is a Mac-only API. On Linux, it is a flag on send.
+ if (result != kInvalidSocket) {
+ int value = 1;
+ if (setsockopt(result, SOL_SOCKET, SO_NOSIGPIPE, &value, sizeof(value))) {
+ close(result);
+ return kInvalidSocket;
+ }
+ }
+#endif
+ return result;
#endif // OS_WIN
}
« no previous file with comments | « no previous file | net/socket/socket_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698