Index: net/socket/socket_posix.cc |
diff --git a/net/socket/socket_posix.cc b/net/socket/socket_posix.cc |
index 19d4343fa4277b53c39bfd0976d98bd5ed04c2fe..8ed912422ffa6cbddeef8c8e1e0f45463985b306 100644 |
--- a/net/socket/socket_posix.cc |
+++ b/net/socket/socket_posix.cc |
@@ -14,6 +14,7 @@ |
#include "base/logging.h" |
#include "base/posix/eintr_wrapper.h" |
#include "base/trace_event/trace_event.h" |
+#include "build/build_config.h" |
#include "net/base/io_buffer.h" |
#include "net/base/ip_endpoint.h" |
#include "net/base/net_errors.h" |
@@ -441,7 +442,15 @@ void SocketPosix::ReadCompleted() { |
} |
int SocketPosix::DoWrite(IOBuffer* buf, int buf_len) { |
+#if defined(OS_LINUX) |
mmenke
2016/06/01 21:45:11
OS_LINUX excludes Android, I believe. Should we a
davidben
2016/06/01 21:50:59
Ugh, so it does. Done.
|
+ // Disable SIGPIPE for this write. Although Chromium globally disables |
+ // SIGPIPE, the net stack may be used in other consumers which do not do |
+ // this. MSG_NOSIGNAL is a Linux-only API. On OS X, this is a setsockopt on |
+ // socket creation. |
+ int rv = HANDLE_EINTR(send(socket_fd_, buf->data(), buf_len, MSG_NOSIGNAL)); |
+#else |
int rv = HANDLE_EINTR(write(socket_fd_, buf->data(), buf_len)); |
+#endif |
return rv >= 0 ? rv : MapSystemError(errno); |
} |