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

Unified Diff: net/socket/tcp_client_socket_libevent.cc

Issue 10803027: Fix TCPClientSocket::GetLocalAddress() to work when socket is not connected. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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/tcp_client_socket_unittest.cc » ('j') | net/socket/tcp_client_socket_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/tcp_client_socket_libevent.cc
diff --git a/net/socket/tcp_client_socket_libevent.cc b/net/socket/tcp_client_socket_libevent.cc
index d139a5478d60a0e99ddcd72553701f4ba97e1647..aa14417e77e5f575241b06c1cd21deee7196a79b 100644
--- a/net/socket/tcp_client_socket_libevent.cc
+++ b/net/socket/tcp_client_socket_libevent.cc
@@ -180,7 +180,7 @@ int TCPClientSocketLibevent::Bind(const IPEndPoint& address) {
if (!address.ToSockAddr(storage.addr, &storage.addr_len))
return ERR_INVALID_ARGUMENT;
- // Create |bound_socket_| and try to bound it to |address|.
+ // Create |bound_socket_| and try to bind it to |address|.
int error = CreateSocket(address.GetFamily(), &bound_socket_);
if (error)
return MapSystemError(error);
@@ -718,8 +718,14 @@ int TCPClientSocketLibevent::GetPeerAddress(IPEndPoint* address) const {
int TCPClientSocketLibevent::GetLocalAddress(IPEndPoint* address) const {
DCHECK(CalledOnValidThread());
DCHECK(address);
- if (!IsConnected())
- return ERR_SOCKET_NOT_CONNECTED;
+ if (socket_ == kInvalidSocket) {
+ if (bind_address_.get()) {
+ *address = *bind_address_;
+ return OK;
+ } else {
+ return ERR_SOCKET_NOT_CONNECTED;
+ }
+ }
SockaddrStorage storage;
if (getsockname(socket_, storage.addr, &storage.addr_len))
« no previous file with comments | « no previous file | net/socket/tcp_client_socket_unittest.cc » ('j') | net/socket/tcp_client_socket_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698