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

Side by Side Diff: runtime/bin/socket_linux.cc

Issue 14766003: Add v6Only named argument to ServerSocket and etc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/socket_android.cc ('k') | runtime/bin/socket_macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_LINUX) 6 #if defined(TARGET_OS_LINUX)
7 7
8 #include <errno.h> // NOLINT 8 #include <errno.h> // NOLINT
9 #include <stdio.h> // NOLINT 9 #include <stdio.h> // NOLINT
10 #include <stdlib.h> // NOLINT 10 #include <stdlib.h> // NOLINT
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 i++; 200 i++;
201 } 201 }
202 } 202 }
203 freeaddrinfo(info); 203 freeaddrinfo(info);
204 return addresses; 204 return addresses;
205 } 205 }
206 206
207 207
208 intptr_t ServerSocket::CreateBindListen(RawAddr addr, 208 intptr_t ServerSocket::CreateBindListen(RawAddr addr,
209 intptr_t port, 209 intptr_t port,
210 intptr_t backlog) { 210 intptr_t backlog,
211 bool v6_only) {
211 intptr_t fd; 212 intptr_t fd;
212 213
213 fd = TEMP_FAILURE_RETRY(socket(addr.ss.ss_family, SOCK_STREAM, 0)); 214 fd = TEMP_FAILURE_RETRY(socket(addr.ss.ss_family, SOCK_STREAM, 0));
214 if (fd < 0) return -1; 215 if (fd < 0) return -1;
215 216
216 FDUtils::SetCloseOnExec(fd); 217 FDUtils::SetCloseOnExec(fd);
217 218
218 int optval = 1; 219 int optval = 1;
219 TEMP_FAILURE_RETRY( 220 TEMP_FAILURE_RETRY(
220 setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval))); 221 setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)));
221 222
222 if (addr.ss.ss_family == AF_INET6) { 223 if (addr.ss.ss_family == AF_INET6) {
223 optval = 0; 224 optval = v6_only ? 1 : 0;
Søren Gjesse 2013/05/01 12:27:47 Isn't the default 1? So we only need to set it if
Anders Johnsen 2013/05/01 12:30:05 It's changeable (0 on my machine).
224 TEMP_FAILURE_RETRY( 225 TEMP_FAILURE_RETRY(
225 setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &optval, sizeof(optval))); 226 setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &optval, sizeof(optval)));
226 } 227 }
227 228
228 SocketAddress::SetAddrPort(&addr, port); 229 SocketAddress::SetAddrPort(&addr, port);
229 if (TEMP_FAILURE_RETRY( 230 if (TEMP_FAILURE_RETRY(
230 bind(fd, 231 bind(fd,
231 &addr.addr, 232 &addr.addr,
232 SocketAddress::GetAddrLength(addr))) < 0) { 233 SocketAddress::GetAddrLength(addr))) < 0) {
233 TEMP_FAILURE_RETRY(close(fd)); 234 TEMP_FAILURE_RETRY(close(fd));
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 SOL_TCP, 303 SOL_TCP,
303 TCP_NODELAY, 304 TCP_NODELAY,
304 reinterpret_cast<char *>(&on), 305 reinterpret_cast<char *>(&on),
305 sizeof(on))) == 0; 306 sizeof(on))) == 0;
306 } 307 }
307 308
308 } // namespace bin 309 } // namespace bin
309 } // namespace dart 310 } // namespace dart
310 311
311 #endif // defined(TARGET_OS_LINUX) 312 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/bin/socket_android.cc ('k') | runtime/bin/socket_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698