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

Unified Diff: net/socket/unix_domain_server_socket_posix.cc

Issue 515653003: Set the internal listen socket only when it opens to socket successfully. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a unittest listening again after failure. Created 6 years, 4 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 | net/socket/unix_domain_server_socket_posix_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/unix_domain_server_socket_posix.cc
diff --git a/net/socket/unix_domain_server_socket_posix.cc b/net/socket/unix_domain_server_socket_posix.cc
index a81f1ce033af0ea6a87f28e4b1c04c8c88012184..4ab0b834e624e81c94da14cc9dae2048b2d49ed0 100644
--- a/net/socket/unix_domain_server_socket_posix.cc
+++ b/net/socket/unix_domain_server_socket_posix.cc
@@ -63,13 +63,13 @@ int UnixDomainServerSocket::ListenWithAddressAndPort(
return ERR_ADDRESS_INVALID;
}
- listen_socket_.reset(new SocketLibevent);
- int rv = listen_socket_->Open(AF_UNIX);
+ scoped_ptr<SocketLibevent> socket(new SocketLibevent);
+ int rv = socket->Open(AF_UNIX);
DCHECK_NE(ERR_IO_PENDING, rv);
if (rv != OK)
return rv;
- rv = listen_socket_->Bind(address);
+ rv = socket->Bind(address);
DCHECK_NE(ERR_IO_PENDING, rv);
if (rv != OK) {
PLOG(ERROR)
@@ -78,7 +78,13 @@ int UnixDomainServerSocket::ListenWithAddressAndPort(
return rv;
}
- return listen_socket_->Listen(backlog);
+ rv = socket->Listen(backlog);
+ DCHECK_NE(ERR_IO_PENDING, rv);
+ if (rv != OK)
+ return rv;
+
+ listen_socket_.swap(socket);
+ return rv;
}
int UnixDomainServerSocket::GetLocalAddress(IPEndPoint* address) const {
« no previous file with comments | « no previous file | net/socket/unix_domain_server_socket_posix_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698