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

Unified Diff: net/socket/socket_posix.cc

Issue 2815993002: Adds a method to TCPServerSocket to adopt a socket. (Closed)
Patch Set: Rebased to fix merge conflict 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
Index: net/socket/socket_posix.cc
diff --git a/net/socket/socket_posix.cc b/net/socket/socket_posix.cc
index 6955aa2a1e83a565c12f2700db5e2d1a618effce..a43f5176409055221b861aec629cfb39db9927c8 100644
--- a/net/socket/socket_posix.cc
+++ b/net/socket/socket_posix.cc
@@ -98,6 +98,16 @@ int SocketPosix::Open(int address_family) {
int SocketPosix::AdoptConnectedSocket(SocketDescriptor socket,
const SockaddrStorage& address) {
+ int rv = AdoptUnconnectedSocket(socket);
+ if (rv != OK) {
+ return rv;
+ }
mmenke 2017/04/21 19:20:38 nit: Don't use braces for one line if bodies.
Raul Vera 2017/05/01 05:35:25 Done. But I'd like to point out that the style gui
mmenke 2017/05/01 18:44:19 Note that you should generally be consistent with
+
+ SetPeerAddress(address);
+ return OK;
+}
+
+int SocketPosix::AdoptUnconnectedSocket(SocketDescriptor socket) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_EQ(kInvalidSocket, socket_fd_);
@@ -109,7 +119,6 @@ int SocketPosix::AdoptConnectedSocket(SocketDescriptor socket,
return rv;
}
- SetPeerAddress(address);
return OK;
}

Powered by Google App Engine
This is Rietveld 408576698