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

Unified Diff: runtime/bin/socket_linux.cc

Issue 171503009: Remove SocketData and now only pass the dart port to epoll. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/socket.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_linux.cc
diff --git a/runtime/bin/socket_linux.cc b/runtime/bin/socket_linux.cc
index db7704b211e3a2d47e29d38c32678992bfbef3b3..133e3335ec939fa747935b487fc2eaef7b159324 100644
--- a/runtime/bin/socket_linux.cc
+++ b/runtime/bin/socket_linux.cc
@@ -60,8 +60,8 @@ bool Socket::Initialize() {
intptr_t Socket::Create(RawAddr addr) {
intptr_t fd;
- fd = TEMP_FAILURE_RETRY_BLOCK_SIGNALS(socket(addr.ss.ss_family, SOCK_STREAM,
- 0));
+ fd = TEMP_FAILURE_RETRY_BLOCK_SIGNALS(socket(
+ addr.ss.ss_family, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0));
if (fd < 0) {
const int kBufferSize = 1024;
char error_buf[kBufferSize];
@@ -69,8 +69,6 @@ intptr_t Socket::Create(RawAddr addr) {
strerror_r(errno, error_buf, kBufferSize));
return -1;
}
-
- FDUtils::SetCloseOnExec(fd);
return fd;
}
@@ -94,9 +92,6 @@ intptr_t Socket::CreateConnect(RawAddr addr, const intptr_t port) {
if (fd < 0) {
return fd;
}
-
- Socket::SetNonBlocking(fd);
-
return Socket::Connect(fd, addr, port);
}
@@ -315,12 +310,12 @@ intptr_t Socket::CreateBindDatagram(
RawAddr* addr, intptr_t port, bool reuseAddress) {
intptr_t fd;
- fd = TEMP_FAILURE_RETRY_BLOCK_SIGNALS(
- socket(addr->addr.sa_family, SOCK_DGRAM, IPPROTO_UDP));
+ fd = TEMP_FAILURE_RETRY_BLOCK_SIGNALS(socket(
+ addr->addr.sa_family,
+ SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK,
+ IPPROTO_UDP));
if (fd < 0) return -1;
- FDUtils::SetCloseOnExec(fd);
-
if (reuseAddress) {
int optval = 1;
VOID_TEMP_FAILURE_RETRY_BLOCK_SIGNALS(
@@ -335,8 +330,6 @@ intptr_t Socket::CreateBindDatagram(
TEMP_FAILURE_RETRY_BLOCK_SIGNALS(close(fd));
return -1;
}
-
- Socket::SetNonBlocking(fd);
return fd;
}
@@ -398,12 +391,10 @@ intptr_t ServerSocket::CreateBindListen(RawAddr addr,
bool v6_only) {
intptr_t fd;
- fd = TEMP_FAILURE_RETRY_BLOCK_SIGNALS(socket(addr.ss.ss_family, SOCK_STREAM,
- 0));
+ fd = TEMP_FAILURE_RETRY_BLOCK_SIGNALS(socket(
+ addr.ss.ss_family, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0));
if (fd < 0) return -1;
- FDUtils::SetCloseOnExec(fd);
-
int optval = 1;
TEMP_FAILURE_RETRY_BLOCK_SIGNALS(
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)));
@@ -440,7 +431,6 @@ intptr_t ServerSocket::CreateBindListen(RawAddr addr,
return -1;
}
- Socket::SetNonBlocking(fd);
return fd;
}
@@ -459,7 +449,8 @@ intptr_t ServerSocket::Accept(intptr_t fd) {
intptr_t socket;
struct sockaddr clientaddr;
socklen_t addrlen = sizeof(clientaddr);
- socket = TEMP_FAILURE_RETRY_BLOCK_SIGNALS(accept(fd, &clientaddr, &addrlen));
+ socket = TEMP_FAILURE_RETRY_BLOCK_SIGNALS(accept4(
+ fd, &clientaddr, &addrlen, SOCK_NONBLOCK | SOCK_CLOEXEC));
if (socket == -1) {
if (IsTemporaryAcceptError(errno)) {
// We need to signal to the caller that this is actually not an
@@ -468,8 +459,6 @@ intptr_t ServerSocket::Accept(intptr_t fd) {
ASSERT(kTemporaryFailure != -1);
socket = kTemporaryFailure;
}
- } else {
- Socket::SetNonBlocking(socket);
}
return socket;
}
@@ -486,16 +475,6 @@ void Socket::Close(intptr_t fd) {
}
-bool Socket::SetNonBlocking(intptr_t fd) {
- return FDUtils::SetNonBlocking(fd);
-}
-
-
-bool Socket::SetBlocking(intptr_t fd) {
- return FDUtils::SetBlocking(fd);
-}
-
-
bool Socket::GetNoDelay(intptr_t fd, bool* enabled) {
int on;
socklen_t len = sizeof(on);
« no previous file with comments | « runtime/bin/socket.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698