face: Implementing forgotten isListening() feature in TcpChannel

Change-Id: Idfcd8337d16b414d2f739f936660dffdce413729
diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp
index 28fdfa5..4c438be 100644
--- a/daemon/face/tcp-channel.cpp
+++ b/daemon/face/tcp-channel.cpp
@@ -16,6 +16,7 @@
 
 TcpChannel::TcpChannel(const tcp::Endpoint& localEndpoint)
   : m_localEndpoint(localEndpoint)
+  , m_isListening(false)
 {
   this->setUri(FaceUri(localEndpoint));
 }
@@ -45,6 +46,8 @@
                            bind(&TcpChannel::handleSuccessfulAccept, this, _1,
                                 clientSocket,
                                 onFaceCreated, onAcceptFailed));
+
+  m_isListening = true;
 }
 
 void
diff --git a/daemon/face/tcp-channel.hpp b/daemon/face/tcp-channel.hpp
index 3c56cb1..e31723b 100644
--- a/daemon/face/tcp-channel.hpp
+++ b/daemon/face/tcp-channel.hpp
@@ -85,6 +85,9 @@
   size_t
   size() const;
 
+  bool
+  isListening() const;
+
 private:
   void
   createFace(const shared_ptr<boost::asio::ip::tcp::socket>& socket,
@@ -128,10 +131,16 @@
   typedef std::map< tcp::Endpoint, shared_ptr<Face> > ChannelFaceMap;
   ChannelFaceMap m_channelFaces;
 
-  bool isListening;
+  bool m_isListening;
   shared_ptr<boost::asio::ip::tcp::acceptor> m_acceptor;
 };
 
+inline bool
+TcpChannel::isListening() const
+{
+  return m_isListening;
+}
+
 } // namespace nfd
 
 #endif // NFD_FACE_TCP_CHANNEL_HPP
diff --git a/tests/face/tcp.cpp b/tests/face/tcp.cpp
index d908804..6fe74e4 100644
--- a/tests/face/tcp.cpp
+++ b/tests/face/tcp.cpp
@@ -169,9 +169,13 @@
   shared_ptr<TcpChannel> channel1 = factory.createChannel("127.0.0.1", "20070");
   factory.createChannel("127.0.0.1", "20071");
 
+  BOOST_CHECK_EQUAL(channel1->isListening(), false);
+
   channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated,   this, _1),
                    bind(&EndToEndFixture::channel1_onConnectFailed, this, _1));
 
+  BOOST_CHECK_EQUAL(channel1->isListening(), true);
+
   factory.createFace(FaceUri("tcp://127.0.0.1:20070"),
                      bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
                      bind(&EndToEndFixture::channel2_onConnectFailed, this, _1));