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

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

Issue 112593003: Fix building on Mac OS (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 7 years 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 | « no previous file | runtime/bin/socket_linux.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 intptr_t fd; 304 intptr_t fd;
305 305
306 fd = TEMP_FAILURE_RETRY( 306 fd = TEMP_FAILURE_RETRY(
307 socket(addr->addr.sa_family, SOCK_DGRAM, IPPROTO_UDP)); 307 socket(addr->addr.sa_family, SOCK_DGRAM, IPPROTO_UDP));
308 if (fd < 0) return -1; 308 if (fd < 0) return -1;
309 309
310 FDUtils::SetCloseOnExec(fd); 310 FDUtils::SetCloseOnExec(fd);
311 311
312 if (reuseAddress) { 312 if (reuseAddress) {
313 int optval = 1; 313 int optval = 1;
314 TEMP_FAILURE_RETRY( 314 VOID_TEMP_FAILURE_RETRY(
315 setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval))); 315 setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)));
316 } 316 }
317 317
318 SocketAddress::SetAddrPort(addr, port); 318 SocketAddress::SetAddrPort(addr, port);
319 if (TEMP_FAILURE_RETRY( 319 if (TEMP_FAILURE_RETRY(
320 bind(fd, 320 bind(fd,
321 &addr->addr, 321 &addr->addr,
322 SocketAddress::GetAddrLength(addr))) < 0) { 322 SocketAddress::GetAddrLength(addr))) < 0) {
323 TEMP_FAILURE_RETRY(close(fd)); 323 TEMP_FAILURE_RETRY(close(fd));
324 return -1; 324 return -1;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 optval = v6_only ? 1 : 0; 357 optval = v6_only ? 1 : 0;
358 TEMP_FAILURE_RETRY( 358 TEMP_FAILURE_RETRY(
359 setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &optval, sizeof(optval))); 359 setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &optval, sizeof(optval)));
360 } 360 }
361 361
362 SocketAddress::SetAddrPort(&addr, port); 362 SocketAddress::SetAddrPort(&addr, port);
363 if (TEMP_FAILURE_RETRY( 363 if (TEMP_FAILURE_RETRY(
364 bind(fd, 364 bind(fd,
365 &addr.addr, 365 &addr.addr,
366 SocketAddress::GetAddrLength(&addr))) < 0) { 366 SocketAddress::GetAddrLength(&addr))) < 0) {
367 TEMP_FAILURE_RETRY(close(fd)); 367 VOID_TEMP_FAILURE_RETRY(close(fd));
368 return -1; 368 return -1;
369 } 369 }
370 370
371 // Test for invalid socket port 65535 (some browsers disallow it). 371 // Test for invalid socket port 65535 (some browsers disallow it).
372 if (port == 0 && Socket::GetPort(fd) == 65535) { 372 if (port == 0 && Socket::GetPort(fd) == 65535) {
373 // Don't close the socket until we have created a new socket, ensuring 373 // Don't close the socket until we have created a new socket, ensuring
374 // that we do not get the bad port number again. 374 // that we do not get the bad port number again.
375 intptr_t new_fd = CreateBindListen(addr, 0, backlog, v6_only); 375 intptr_t new_fd = CreateBindListen(addr, 0, backlog, v6_only);
376 int err = errno; 376 int err = errno;
377 VOID_TEMP_FAILURE_RETRY(close(fd)); 377 VOID_TEMP_FAILURE_RETRY(close(fd));
378 errno = err; 378 errno = err;
379 return new_fd; 379 return new_fd;
380 } 380 }
381 381
382 if (TEMP_FAILURE_RETRY(listen(fd, backlog > 0 ? backlog : SOMAXCONN)) != 0) { 382 if (TEMP_FAILURE_RETRY(listen(fd, backlog > 0 ? backlog : SOMAXCONN)) != 0) {
383 TEMP_FAILURE_RETRY(close(fd)); 383 VOID_TEMP_FAILURE_RETRY(close(fd));
384 return -1; 384 return -1;
385 } 385 }
386 386
387 Socket::SetNonBlocking(fd); 387 Socket::SetNonBlocking(fd);
388 return fd; 388 return fd;
389 } 389 }
390 390
391 391
392 static bool IsTemporaryAcceptError(int error) { 392 static bool IsTemporaryAcceptError(int error) {
393 // On Android a number of protocol errors should be treated as EAGAIN. 393 // On Android a number of protocol errors should be treated as EAGAIN.
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 mreq.gr_interface = interfaceIndex; 569 mreq.gr_interface = interfaceIndex;
570 memmove(&mreq.gr_group, &addr->ss, SocketAddress::GetAddrLength(addr)); 570 memmove(&mreq.gr_group, &addr->ss, SocketAddress::GetAddrLength(addr));
571 return TEMP_FAILURE_RETRY(setsockopt( 571 return TEMP_FAILURE_RETRY(setsockopt(
572 fd, proto, MCAST_LEAVE_GROUP, &mreq, sizeof(mreq))) == 0; 572 fd, proto, MCAST_LEAVE_GROUP, &mreq, sizeof(mreq))) == 0;
573 } 573 }
574 574
575 } // namespace bin 575 } // namespace bin
576 } // namespace dart 576 } // namespace dart
577 577
578 #endif // defined(TARGET_OS_ANDROID) 578 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/socket_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698