aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/src/hicn/transport/protocols/protocol.cc
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-10-15 18:08:41 +0200
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-10-22 11:01:41 +0200
commit755c6833ae2d2eee87e80ed3b84c75e968f48c46 (patch)
tree653345beb889acabc83b3b3b03e849fa34b1baac /libtransport/src/hicn/transport/protocols/protocol.cc
parent7204bac00804448a797d4e76ced04a3b84d0d741 (diff)
[HICN-328] Reworking setSocketOption and getSocketOption to be thread-safe
Change-Id: Ie22572822b9ac1e6c300fd7982035c799546bd76 Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Diffstat (limited to 'libtransport/src/hicn/transport/protocols/protocol.cc')
-rw-r--r--libtransport/src/hicn/transport/protocols/protocol.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/libtransport/src/hicn/transport/protocols/protocol.cc b/libtransport/src/hicn/transport/protocols/protocol.cc
index 9caa2eca7..8da9529d6 100644
--- a/libtransport/src/hicn/transport/protocols/protocol.cc
+++ b/libtransport/src/hicn/transport/protocols/protocol.cc
@@ -23,23 +23,28 @@ namespace protocol {
using namespace interface;
TransportProtocol::TransportProtocol(interface::ConsumerSocket *icn_socket)
- : socket_(icn_socket), is_running_(false) {
+ : socket_(icn_socket), is_running_(false), is_first_(false) {
socket_->getSocketOption(GeneralTransportOptions::PORTAL, portal_);
}
int TransportProtocol::start() {
- // If the protocol is already running, return
+ // If the protocol is already running, return otherwise set as running
if (is_running_) return -1;
- // Set the protocol as running
- is_running_ = true;
-
// Reset the protocol state machine
reset();
+ // Set it is the first time we schedule an interest
+ is_first_ = true;
+
// Schedule next interests
scheduleNextInterests();
+ is_first_ = false;
+
+ // Set the protocol as running
+ is_running_ = true;
+
// Start Event loop
portal_->runEventsLoop();