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

Side by Side 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, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | net/socket/socket_posix.cc » ('j') | net/socket/socket_posix.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/socket/socket_descriptor.h" 5 #include "net/socket/socket_descriptor.h"
6 6
7 #if defined(OS_POSIX) 7 #if defined(OS_POSIX)
8 #include <sys/types.h> 8 #include <sys/types.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 #endif 10 #endif
(...skipping 13 matching lines...) Expand all
24 if (result != kInvalidSocket && family == AF_INET6) { 24 if (result != kInvalidSocket && family == AF_INET6) {
25 DWORD value = 0; 25 DWORD value = 0;
26 if (setsockopt(result, IPPROTO_IPV6, IPV6_V6ONLY, 26 if (setsockopt(result, IPPROTO_IPV6, IPV6_V6ONLY,
27 reinterpret_cast<const char*>(&value), sizeof(value))) { 27 reinterpret_cast<const char*>(&value), sizeof(value))) {
28 closesocket(result); 28 closesocket(result);
29 return kInvalidSocket; 29 return kInvalidSocket;
30 } 30 }
31 } 31 }
32 return result; 32 return result;
33 #else // OS_WIN 33 #else // OS_WIN
34 return ::socket(family, type, protocol); 34 SocketDescriptor result = ::socket(family, type, protocol);
35 #if defined(OS_MACOSX)
36 // Disable SIGPIPE on this socket. Although Chromium globally disables
37 // SIGPIPE, the net stack may be used in other consumers which do not do
38 // this. SO_NOSIGPIPE is a Mac-only API. On Linux, it is a flag on send.
39 if (result != kInvalidSocket) {
40 int value = 1;
41 if (setsockopt(result, SOL_SOCKET, SO_NOSIGPIPE, &value, sizeof(value))) {
42 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-
43 return kInvalidSocket;
44 }
45 }
46 #endif
47 return result;
35 #endif // OS_WIN 48 #endif // OS_WIN
36 49
37 } 50 }
38 51
39 } // namespace net 52 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/socket/socket_posix.cc » ('j') | net/socket/socket_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698