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

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

Issue 907883002: Remove SetNonBlocking/SetBlocking methods from Socket and add missing close-on-exec (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 5 years, 10 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 socket = TEMP_FAILURE_RETRY(accept(fd, &clientaddr, &addrlen)); 420 socket = TEMP_FAILURE_RETRY(accept(fd, &clientaddr, &addrlen));
421 if (socket == -1) { 421 if (socket == -1) {
422 if (IsTemporaryAcceptError(errno)) { 422 if (IsTemporaryAcceptError(errno)) {
423 // We need to signal to the caller that this is actually not an 423 // We need to signal to the caller that this is actually not an
424 // error. We got woken up from the poll on the listening socket, 424 // error. We got woken up from the poll on the listening socket,
425 // but there is no connection ready to be accepted. 425 // but there is no connection ready to be accepted.
426 ASSERT(kTemporaryFailure != -1); 426 ASSERT(kTemporaryFailure != -1);
427 socket = kTemporaryFailure; 427 socket = kTemporaryFailure;
428 } 428 }
429 } else { 429 } else {
430 FDUtils::SetCloseOnExec(socket);
430 FDUtils::SetNonBlocking(socket); 431 FDUtils::SetNonBlocking(socket);
431 FDUtils::SetCloseOnExec(socket);
432 } 432 }
433 return socket; 433 return socket;
434 } 434 }
435 435
436 436
437 void Socket::Close(intptr_t fd) { 437 void Socket::Close(intptr_t fd) {
438 ASSERT(fd >= 0); 438 ASSERT(fd >= 0);
439 VOID_TEMP_FAILURE_RETRY(close(fd)); 439 VOID_TEMP_FAILURE_RETRY(close(fd));
440 } 440 }
441 441
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 mreq.gr_interface = interfaceIndex; 552 mreq.gr_interface = interfaceIndex;
553 memmove(&mreq.gr_group, &addr->ss, SocketAddress::GetAddrLength(addr)); 553 memmove(&mreq.gr_group, &addr->ss, SocketAddress::GetAddrLength(addr));
554 return NO_RETRY_EXPECTED( 554 return NO_RETRY_EXPECTED(
555 setsockopt(fd, proto, MCAST_LEAVE_GROUP, &mreq, sizeof(mreq))) == 0; 555 setsockopt(fd, proto, MCAST_LEAVE_GROUP, &mreq, sizeof(mreq))) == 0;
556 } 556 }
557 557
558 } // namespace bin 558 } // namespace bin
559 } // namespace dart 559 } // namespace dart
560 560
561 #endif // defined(TARGET_OS_LINUX) 561 #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