diff options
author | Mauro Sardara <msardara@cisco.com> | 2020-06-02 18:52:39 +0200 |
---|---|---|
committer | Angelo Mantellini <angelo.mantellini@cisco.com> | 2020-06-03 16:21:49 +0200 |
commit | 5d8156ea4c34f9a3cb986da16a71faebfb2add6b (patch) | |
tree | 5895f7546c91eab1c6cad917f3a41594a543ca64 /apps/http-proxy/src/icn_receiver.cc | |
parent | 15458966a342caa0912b7806a755d0d8277ca00f (diff) |
[HICN-622] Add stop() functionality to http proxy.
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Change-Id: I9091cd8ef0f9da869b886541a0116adf3f30e6b9
Signed-off-by: Angelo Mantellini <angelo.mantellini@cisco.com>
Diffstat (limited to 'apps/http-proxy/src/icn_receiver.cc')
-rw-r--r-- | apps/http-proxy/src/icn_receiver.cc | 25 |
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, |