Workaround for issue 3927 to allow localhost IP even if it doesn't match the local turn port
BUG=3927
R=pthatcher@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/28329004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7941 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/base/virtualsocketserver.cc b/webrtc/base/virtualsocketserver.cc
index c2937ba..59587bb 100644
--- a/webrtc/base/virtualsocketserver.cc
+++ b/webrtc/base/virtualsocketserver.cc
@@ -51,6 +51,7 @@
enum {
MSG_ID_PACKET,
+ MSG_ID_ADDRESS_BOUND,
MSG_ID_CONNECT,
MSG_ID_DISCONNECT,
};
@@ -130,11 +131,14 @@
return remote_addr_;
}
-// Used by server sockets to set the local address without binding.
void VirtualSocket::SetLocalAddress(const SocketAddress& addr) {
local_addr_ = addr;
}
+void VirtualSocket::SetAlternativeLocalAddress(const SocketAddress& addr) {
+ alternative_local_addr_ = addr;
+}
+
int VirtualSocket::Bind(const SocketAddress& addr) {
if (!local_addr_.IsNil()) {
error_ = EINVAL;
@@ -148,6 +152,9 @@
} else {
bound_ = true;
was_any_ = addr.IsAnyIP();
+ // Post a message here such that test case could have chance to
+ // process the local address. (i.e. SetAlternativeLocalAddress).
+ server_->msg_queue_->Post(this, MSG_ID_ADDRESS_BOUND);
}
return result;
}
@@ -411,6 +418,8 @@
SignalCloseEvent(this, error);
}
}
+ } else if (pmsg->message_id == MSG_ID_ADDRESS_BOUND) {
+ SignalAddressReady(this, GetLocalAddress());
} else {
ASSERT(false);
}