face: Refactor internal PIT to use scheduled events
The commit also changes how face is paused when there are no pending
interests left and there are no registered prefixes with local
forwarder: data structures for pending interests and registered prefixes
will fire up a signal when they become empty.
Change-Id: I6b87a44b0c8bc766865a51962ecacaec85b4adad
Refs: #1372, #2518
diff --git a/src/transport/stream-transport.hpp b/src/transport/stream-transport.hpp
index 737842c..d7f2e49 100644
--- a/src/transport/stream-transport.hpp
+++ b/src/transport/stream-transport.hpp
@@ -127,6 +127,9 @@
}
}
+ /**
+ * @warning Must not be called directly or indirectly from within handleAsyncReceive invocation
+ */
void
resume()
{
diff --git a/src/transport/tcp-transport.cpp b/src/transport/tcp-transport.cpp
index a5b311f..c43790f 100644
--- a/src/transport/tcp-transport.cpp
+++ b/src/transport/tcp-transport.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2014 Regents of the University of California.
+ * Copyright (c) 2013-2015 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -41,52 +41,39 @@
TcpTransport::create(const ConfigFile& config)
{
const auto hostAndPort(getDefaultSocketHostAndPort(config));
- return make_shared<TcpTransport>(hostAndPort.first,
- hostAndPort.second);
+ return make_shared<TcpTransport>(hostAndPort.first, hostAndPort.second);
}
std::pair<std::string, std::string>
TcpTransport::getDefaultSocketHostAndPort(const ConfigFile& config)
{
const ConfigFile::Parsed& parsed = config.getParsedConfiguration();
+
std::string host = "localhost";
std::string port = "6363";
- try
- {
- const util::FaceUri uri(parsed.get<std::string>("transport"));
+ try {
+ const util::FaceUri uri(parsed.get<std::string>("transport", "tcp://" + host));
- const std::string scheme = uri.getScheme();
- if (scheme != "tcp" && scheme != "tcp4" && scheme != "tcp6")
- {
- throw Transport::Error("Cannot create TcpTransport from \"" +
- scheme + "\" URI");
- }
-
- if (!uri.getHost().empty())
- {
- host = uri.getHost();
- }
-
- if (!uri.getPort().empty())
- {
- port = uri.getPort();
- }
- }
- catch (const boost::property_tree::ptree_bad_path& error)
- {
- // no transport specified, use default host and port
- }
- catch (const boost::property_tree::ptree_bad_data& error)
- {
- throw ConfigFile::Error(error.what());
- }
- catch (const util::FaceUri::Error& error)
- {
- throw ConfigFile::Error(error.what());
+ const std::string scheme = uri.getScheme();
+ if (scheme != "tcp" && scheme != "tcp4" && scheme != "tcp6") {
+ throw Transport::Error("Cannot create TcpTransport from \"" +
+ scheme + "\" URI");
}
- return std::make_pair(host, port);
+ if (!uri.getHost().empty()) {
+ host = uri.getHost();
+ }
+
+ if (!uri.getPort().empty()) {
+ port = uri.getPort();
+ }
+ }
+ catch (const util::FaceUri::Error& error) {
+ throw ConfigFile::Error(error.what());
+ }
+
+ return {host, port};
}
void