summaryrefslogtreecommitdiffstats
path: root/apps/http-proxy/src/icn_receiver.cc
diff options
context:
space:
mode:
authorAngelo Mantellini <angelo.mantellini@cisco.com>2020-06-03 14:47:16 +0000
committerGerrit Code Review <gerrit@fd.io>2020-06-03 14:47:16 +0000
commitf3f4f8cf18bf21c522e73571d183c95ef5dcb33c (patch)
tree0eb89fe5ed20ea42985f49a3f0d40f32db25ae0f /apps/http-proxy/src/icn_receiver.cc
parent8340427544b3adedd57736fb13ca69c5549b6fc1 (diff)
parent5d8156ea4c34f9a3cb986da16a71faebfb2add6b (diff)
Merge "[HICN-622] Add stop() functionality to http proxy."
Diffstat (limited to 'apps/http-proxy/src/icn_receiver.cc')
-rw-r--r--apps/http-proxy/src/icn_receiver.cc25
1 files changed, 12 insertions, 13 deletions
diff --git a/apps/http-proxy/src/icn_receiver.cc b/apps/http-proxy/src/icn_receiver.cc
index 6ccd2dc31..34b85f9c9 100644
--- a/apps/http-proxy/src/icn_receiver.cc
+++ b/apps/http-proxy/src/icn_receiver.cc
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-#include "icn_receiver.h"
+#include <hicn/http-proxy/icn_receiver.h>
#include <hicn/transport/core/interest.h>
#include <hicn/transport/http/default_values.h>
@@ -23,8 +23,8 @@
#include <functional>
#include <memory>
-#include "HTTP1.xMessageFastParser.h"
-#include "utils.h"
+#include <hicn/http-proxy/HTTP1.xMessageFastParser.h>
+#include <hicn/http-proxy/utils.h>
namespace transport {
@@ -42,7 +42,6 @@ AsyncConsumerProducer::AsyncConsumerProducer(
cache_size_(std::stoul(cache_size)),
mtu_(std::stoul(mtu)),
request_counter_(0),
- signals_(io_service_, SIGINT, SIGQUIT),
connector_(io_service_, ip_address_, port_,
std::bind(&AsyncConsumerProducer::publishContent, this,
std::placeholders::_1, std::placeholders::_2,
@@ -76,15 +75,6 @@ AsyncConsumerProducer::AsyncConsumerProducer(
}
producer_socket_.registerPrefix(prefix_);
-
- // Let the main thread to catch SIGINT and SIGQUIT
- signals_.async_wait(
- [this](const std::error_code& errorCode, int signal_number) {
- TRANSPORT_LOGI("Number of requests processed by plugin: %lu",
- (unsigned long)request_counter_);
- producer_socket_.stop();
- connector_.close();
- });
}
void AsyncConsumerProducer::start() {
@@ -100,6 +90,15 @@ void AsyncConsumerProducer::run() {
}
}
+void AsyncConsumerProducer::stop() {
+ io_service_.post([this]() {
+ TRANSPORT_LOGI("Number of requests processed by plugin: %lu",
+ (unsigned long)request_counter_);
+ producer_socket_.stop();
+ connector_.close();
+ });
+}
+
void AsyncConsumerProducer::doReceive() {
producer_socket_.setSocketOption(
interface::ProducerCallbacksOptions::CACHE_MISS,