face: Implementing close operation and many related fixes in TcpFace and TcpChannel
Change-Id: Ib6b751e80454e149bf94f3867663d5e705cbf4a0
refs: #1250, #1248
diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp
index 026c338..087a24c 100644
--- a/daemon/face/tcp-channel.cpp
+++ b/daemon/face/tcp-channel.cpp
@@ -111,19 +111,33 @@
onConnectFailed));
}
+size_t
+TcpChannel::size() const
+{
+ return m_channelFaces.size();
+}
void
TcpChannel::createFace(const shared_ptr<ip::tcp::socket>& socket,
const FaceCreatedCallback& onFaceCreated)
{
- shared_ptr<TcpFace> face = make_shared<TcpFace>(boost::cref(socket));
- onFaceCreated(face);
-
tcp::Endpoint remoteEndpoint = socket->remote_endpoint();
+
+ shared_ptr<TcpFace> face = make_shared<TcpFace>(boost::cref(socket));
+ face->onFail += bind(&TcpChannel::afterFaceFailed, this, remoteEndpoint);
+
+ onFaceCreated(face);
m_channelFaces[remoteEndpoint] = face;
}
void
+TcpChannel::afterFaceFailed(tcp::Endpoint &remoteEndpoint)
+{
+ NFD_LOG_DEBUG("afterFaceFailed: " << remoteEndpoint);
+ m_channelFaces.erase(remoteEndpoint);
+}
+
+void
TcpChannel::handleSuccessfulAccept(const boost::system::error_code& error,
const shared_ptr<boost::asio::ip::tcp::socket>& socket,
const FaceCreatedCallback& onFaceCreated,