Chromium Code Reviews| Index: net/socket/socket_descriptor.cc |
| diff --git a/net/socket/socket_descriptor.cc b/net/socket/socket_descriptor.cc |
| index b10f2dcb41d6b682d48b9c63d5a3c9d3cec88e54..6dfcc4966d7263e512786eab44bf370f59a62040 100644 |
| --- a/net/socket/socket_descriptor.cc |
| +++ b/net/socket/socket_descriptor.cc |
| @@ -31,7 +31,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); |
|
mmenke
2016/06/01 21:45:11
closesocket
davidben
2016/06/01 21:50:59
It's just close on UNIX. closesocket is a Windows-
|
| + return kInvalidSocket; |
| + } |
| + } |
| +#endif |
| + return result; |
| #endif // OS_WIN |
| } |