aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/src/protocols/protocol.cc
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2020-05-14 20:21:02 +0200
committerMauro Sardara <msardara@cisco.com>2020-05-20 10:45:53 +0200
commit81fb39606b069fbece973995572fa7f90ea1950a (patch)
tree10c1534707c725eb654741e5b4d280a17ef0c0dc /libtransport/src/protocols/protocol.cc
parent67b86555b33c641de14d3c1d0864e571370a71e6 (diff)
[HICN-613] Add io_service to ConsumerSocket constructor.
Change-Id: Ic1952388e1d2b1e7457c71ae8a959d97aa0cd2d6 Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'libtransport/src/protocols/protocol.cc')
-rw-r--r--libtransport/src/protocols/protocol.cc23
1 files changed, 15 insertions, 8 deletions
diff --git a/libtransport/src/protocols/protocol.cc b/libtransport/src/protocols/protocol.cc
index 8463f84f9..d1bd566a0 100644
--- a/libtransport/src/protocols/protocol.cc
+++ b/libtransport/src/protocols/protocol.cc
@@ -14,7 +14,6 @@
*/
#include <hicn/transport/interfaces/socket_consumer.h>
-
#include <implementation/socket_consumer.h>
#include <protocols/protocol.h>
@@ -74,6 +73,7 @@ int TransportProtocol::start() {
&verification_failed_callback_);
socket_->getSocketOption(ConsumerCallbacksOptions::READ_CALLBACK,
&on_payload_);
+ socket_->getSocketOption(GeneralTransportOptions::ASYNC_MODE, is_async_);
// Schedule next interests
scheduleNextInterests();
@@ -83,18 +83,25 @@ int TransportProtocol::start() {
// Set the protocol as running
is_running_ = true;
- // Start Event loop
- portal_->runEventsLoop();
+ if (!is_async_) {
+ // Start Event loop
+ portal_->runEventsLoop();
- // Not running anymore
- is_running_ = false;
+ // Not running anymore
+ is_running_ = false;
+ }
return 0;
}
void TransportProtocol::stop() {
is_running_ = false;
- portal_->stopEventsLoop();
+
+ if (!is_async_) {
+ portal_->stopEventsLoop();
+ } else {
+ portal_->clear();
+ }
}
void TransportProtocol::resume() {
@@ -110,6 +117,8 @@ void TransportProtocol::resume() {
}
void TransportProtocol::onContentReassembled(std::error_code ec) {
+ stop();
+
if (!on_payload_) {
throw errors::RuntimeException(
"The read callback must be installed in the transport before "
@@ -122,8 +131,6 @@ void TransportProtocol::onContentReassembled(std::error_code ec) {
} else {
on_payload_->readError(ec);
}
-
- stop();
}
} // end namespace protocol