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

Unified Diff: webrtc/p2p/base/tcpport.cc

Issue 2936553003: Adding PortAllocator option to support cases where sockets can't be bound. (Closed)
Patch Set: Comment fixes Created 3 years, 6 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: webrtc/p2p/base/tcpport.cc
diff --git a/webrtc/p2p/base/tcpport.cc b/webrtc/p2p/base/tcpport.cc
index 79843d82de729eba851360513815e0334a5b7c99..4fd527e5132a6a25e67b38e18d5adb4b48da5d01 100644
--- a/webrtc/p2p/base/tcpport.cc
+++ b/webrtc/p2p/base/tcpport.cc
@@ -96,23 +96,9 @@ TCPPort::TCPPort(rtc::Thread* thread,
error_(0) {
// TODO(mallinath) - Set preference value as per RFC 6544.
// http://b/issue?id=7141794
-}
-
-bool TCPPort::Init() {
if (allow_listen_) {
- // Treat failure to create or bind a TCP socket as fatal. This
- // should never happen.
- socket_ = socket_factory()->CreateServerTcpSocket(
- rtc::SocketAddress(ip(), 0), min_port(), max_port(),
- false /* ssl */);
- if (!socket_) {
- LOG_J(LS_ERROR, this) << "TCP socket creation failed.";
- return false;
- }
- socket_->SignalNewConnection.connect(this, &TCPPort::OnNewConnection);
- socket_->SignalAddressReady.connect(this, &TCPPort::OnAddressReady);
+ TryCreateServerSocket();
}
- return true;
}
TCPPort::~TCPPort() {
@@ -274,6 +260,18 @@ void TCPPort::OnNewConnection(rtc::AsyncPacketSocket* socket,
incoming_.push_back(incoming);
}
+void TCPPort::TryCreateServerSocket() {
+ socket_ = socket_factory()->CreateServerTcpSocket(
+ rtc::SocketAddress(ip(), 0), min_port(), max_port(), false /* ssl */);
+ if (!socket_) {
+ LOG_J(LS_WARNING, this)
+ << "TCP server socket creation failed; continuing anyway.";
+ return;
+ }
+ socket_->SignalNewConnection.connect(this, &TCPPort::OnNewConnection);
+ socket_->SignalAddressReady.connect(this, &TCPPort::OnAddressReady);
+}
+
rtc::AsyncPacketSocket* TCPPort::GetIncoming(
const rtc::SocketAddress& addr, bool remove) {
rtc::AsyncPacketSocket* socket = NULL;

Powered by Google App Engine
This is Rietveld 408576698