face: Don't crash when attempting to create UdpFace over a half-working connection

Change-Id: Ib32128074f8dfe834fde033517325f994d648767
Refs: #2311
This commit is contained in:
Alexander Afanasyev committed 2014-12-18 13:12:42 -08:00
1 parent b9d439d202
commit c5173de511
1 file changed
+7 -1
+7 -1
View File
@@ -229,7 +229,13 @@ UdpChannel::newPeer(const boost::system::error_code& error,
clientSocket->open(m_localEndpoint.protocol());
clientSocket->set_option(ip::udp::socket::reuse_address(true));
clientSocket->bind(m_localEndpoint);
clientSocket->connect(m_newRemoteEndpoint);
boost::system::error_code ec;
clientSocket->connect(m_newRemoteEndpoint, ec);
if (ec) {
NFD_LOG_WARN("Error while creating on-demand UDP face from " << m_newRemoteEndpoint << ": "
<< boost::system::system_error(ec).what());
return;
}
face = createFace(clientSocket,
onFaceCreatedNewPeerCallback,