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

Unified Diff: net/socket/socket_posix.cc

Issue 2815993002: Adds a method to TCPServerSocket to adopt a socket. (Closed)
Patch Set: Refined GetSocketDescriptor per review. Created 3 years, 8 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 | « net/socket/socket_posix.h ('k') | net/socket/tcp_server_socket.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/socket_posix.cc
diff --git a/net/socket/socket_posix.cc b/net/socket/socket_posix.cc
index 6955aa2a1e83a565c12f2700db5e2d1a618effce..5900a5c7952a911c1299be2376fef0fda8c423e7 100644
--- a/net/socket/socket_posix.cc
+++ b/net/socket/socket_posix.cc
@@ -98,6 +98,15 @@ int SocketPosix::Open(int address_family) {
int SocketPosix::AdoptConnectedSocket(SocketDescriptor socket,
const SockaddrStorage& address) {
+ int rv = AdoptUnconnectedSocket(socket);
+ if (rv != OK)
+ return rv;
+
+ SetPeerAddress(address);
+ return OK;
+}
+
+int SocketPosix::AdoptUnconnectedSocket(SocketDescriptor socket) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_EQ(kInvalidSocket, socket_fd_);
@@ -109,7 +118,6 @@ int SocketPosix::AdoptConnectedSocket(SocketDescriptor socket,
return rv;
}
- SetPeerAddress(address);
return OK;
}
« no previous file with comments | « net/socket/socket_posix.h ('k') | net/socket/tcp_server_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698