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

Unified Diff: tools/android/forwarder2/socket.cc

Issue 10957052: Adapt python scripts to use the new Forwarder2 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 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 | « tools/android/forwarder2/host_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/android/forwarder2/socket.cc
diff --git a/tools/android/forwarder2/socket.cc b/tools/android/forwarder2/socket.cc
index 898afc3d4b4dccfee8a75879a7d8bbac162668c1..a531fc0e703ec370a2060a201288022719c21fa1 100644
--- a/tools/android/forwarder2/socket.cc
+++ b/tools/android/forwarder2/socket.cc
@@ -129,7 +129,6 @@ bool Socket::InitUnixSocket(const std::string& path, bool abstract) {
abstract_ = abstract;
family_ = PF_UNIX;
addr_.addr_un.sun_family = family_;
-
if (abstract) {
// Copied from net/base/unix_domain_socket_posix.cc
// Convert the path given into abstract socket name. It must start with
@@ -143,14 +142,12 @@ bool Socket::InitUnixSocket(const std::string& path, bool abstract) {
memcpy(addr_.addr_un.sun_path, path.c_str(), path.size());
addr_len_ = sizeof(sockaddr_un);
}
-
addr_ptr_ = reinterpret_cast<sockaddr*>(&addr_.addr_un);
return InitSocketInternal();
}
bool Socket::InitTcpSocket(const std::string& host, int port) {
port_ = port;
-
if (host.empty()) {
// Use localhost: INADDR_LOOPBACK
family_ = AF_INET;
@@ -180,7 +177,7 @@ bool Socket::BindAndListen() {
SetSocketError();
return false;
}
- if (port_ == 0) {
+ if (port_ == 0 && (family_ == AF_INET || family_ == AF_INET6)) {
Philippe 2012/09/26 00:15:46 Nit: I think that this could be factored out into
felipeg 2012/09/26 00:34:28 Done.
SockAddr addr;
memset(&addr, 0, sizeof(addr));
socklen_t addrlen = 0;
@@ -225,7 +222,7 @@ bool Socket::Accept(Socket* new_socket) {
}
bool Socket::Connect() {
- // Set non-block because we use select.
+ // Set non-block because we use select for connect.
fcntl(socket_, F_SETFL, fcntl(socket_, F_GETFL) | O_NONBLOCK);
Philippe 2012/09/26 00:15:46 Nit: maybe store the result of fcntl() into a cons
felipeg 2012/09/26 00:34:28 Done.
errno = 0;
if (HANDLE_EINTR(connect(socket_, addr_ptr_, addr_len_)) < 0 &&
@@ -238,6 +235,8 @@ bool Socket::Connect() {
SetSocketError();
return false;
}
+ // Disable non-block since our code assumes blocking semantics.
+ fcntl(socket_, F_SETFL, fcntl(socket_, F_GETFL) & ~O_NONBLOCK);
digit1 2012/09/26 00:19:04 I agree with Philippe that this kind of assumption
felipeg 2012/09/26 00:34:28 Done.
return true;
}
« no previous file with comments | « tools/android/forwarder2/host_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698