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

Unified Diff: mojo/shell/domain_socket/socket_libevent.cc

Issue 670773004: Update socket_libevent.cc to build on android (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/domain_socket/socket_libevent.cc
diff --git a/mojo/shell/domain_socket/socket_libevent.cc b/mojo/shell/domain_socket/socket_libevent.cc
index 8e98d7c2b333ca4ac0e0229899cbe2cc3ed05c41..cf4bd7912881e66ca994b474f44f5e16d95bc5eb 100644
--- a/mojo/shell/domain_socket/socket_libevent.cc
+++ b/mojo/shell/domain_socket/socket_libevent.cc
@@ -63,6 +63,13 @@ int MapConnectError(int os_error) {
}
}
+int SetNonBlocking(int fd) {
+ int flags = fcntl(fd, F_GETFL, 0);
+ if (-1 == flags)
+ return flags;
+ return fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+}
+
} // namespace
SocketLibevent::SocketLibevent()
@@ -79,9 +86,19 @@ int SocketLibevent::Open(int address_family) {
DCHECK(address_family == AF_INET || address_family == AF_INET6 ||
address_family == AF_UNIX);
+ int socket_type = SOCK_STREAM;
+#ifdef SOCK_NONBLOCK
+ socket_type |= SOCK_NONBLOCK;
+#endif
socket_fd_ = ::socket(address_family,
- SOCK_STREAM | SOCK_NONBLOCK,
+ socket_type,
address_family == AF_UNIX ? 0 : IPPROTO_TCP);
+#ifndef SOCK_NONBLOCK
+ if (SetNonBlocking(socket_fd_) != 0) {
+ PLOG(ERROR) << "SetNonBlocking() returned an error, errno=" << errno;
+ return net::MapSystemError(errno);
+ }
+#endif
if (socket_fd_ < 0) {
PLOG(ERROR) << "CreatePlatformSocket() returned an error, errno=" << errno;
return net::MapSystemError(errno);
@@ -90,15 +107,6 @@ int SocketLibevent::Open(int address_family) {
return net::OK;
}
-namespace {
-int SetNonBlocking(int fd) {
- int flags = fcntl(fd, F_GETFL, 0);
- if (-1 == flags)
- return flags;
- return fcntl(fd, F_SETFL, flags | O_NONBLOCK);
-}
-} // namespace
-
int SocketLibevent::AdoptConnectedSocket(SocketDescriptor socket,
const SockaddrStorage& address) {
DCHECK(thread_checker_.CalledOnValidThread());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698