diff options
author | Mauro Sardara <msardara@cisco.com> | 2020-06-09 00:03:15 +0200 |
---|---|---|
committer | Mauro Sardara <msardara@cisco.com> | 2020-06-09 01:15:22 +0200 |
commit | a84ff82bb37ac53f20639d6e5e7f19d002459f31 (patch) | |
tree | e2ff9697793c320aaf17da2dd24b3611d64aa112 /libtransport | |
parent | 37819ae5a3631afc8329d05d73ead9091fc513b3 (diff) |
[HICN-623] Initialize is_async in ConsumerSocket constructor.
Also force transports to use base method TransportProtocol::start() instead
of redefining their own start(), in order to have the callbacks and the
boolean is_async_ initialized upon protocol start.
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Change-Id: I780b26cca5b8dc59f0def5c08a032bbc90371acd
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'libtransport')
-rw-r--r-- | libtransport/src/implementation/socket_consumer.h | 1 | ||||
-rw-r--r-- | libtransport/src/protocols/protocol.cc | 11 | ||||
-rw-r--r-- | libtransport/src/protocols/rtc.cc | 26 | ||||
-rw-r--r-- | libtransport/src/protocols/rtc.h | 3 |
4 files changed, 18 insertions, 23 deletions
diff --git a/libtransport/src/implementation/socket_consumer.h b/libtransport/src/implementation/socket_consumer.h index 175678209..5e5073956 100644 --- a/libtransport/src/implementation/socket_consumer.h +++ b/libtransport/src/implementation/socket_consumer.h @@ -54,6 +54,7 @@ class ConsumerSocket : public Socket<BasePortal> { rate_estimation_observer_(nullptr), rate_estimation_batching_parameter_(default_values::batch), rate_estimation_choice_(0), + is_async_(false), verifier_(std::make_shared<utils::Verifier>()), verify_signature_(false), key_content_(false), diff --git a/libtransport/src/protocols/protocol.cc b/libtransport/src/protocols/protocol.cc index d1bd566a0..451fef80d 100644 --- a/libtransport/src/protocols/protocol.cc +++ b/libtransport/src/protocols/protocol.cc @@ -48,12 +48,6 @@ int TransportProtocol::start() { // If the protocol is already running, return otherwise set as running if (is_running_) return -1; - // Reset the protocol state machine - reset(); - - // Set it is the first time we schedule an interest - is_first_ = true; - // Get all callbacks references before starting socket_->getSocketOption(ConsumerCallbacksOptions::INTEREST_RETRANSMISSION, &on_interest_retransmission_); @@ -75,6 +69,11 @@ int TransportProtocol::start() { &on_payload_); socket_->getSocketOption(GeneralTransportOptions::ASYNC_MODE, is_async_); + // Set it is the first time we schedule an interest + is_first_ = true; + + // Reset the protocol state machine + reset(); // Schedule next interests scheduleNextInterests(); diff --git a/libtransport/src/protocols/rtc.cc b/libtransport/src/protocols/rtc.cc index 3b10c7467..b1502f51f 100644 --- a/libtransport/src/protocols/rtc.cc +++ b/libtransport/src/protocols/rtc.cc @@ -38,24 +38,11 @@ RTCTransportProtocol::RTCTransportProtocol( sentinel_timer_ = std::make_unique<asio::steady_timer>(portal_->getIoService()); round_timer_ = std::make_unique<asio::steady_timer>(portal_->getIoService()); - reset(); + initParams(); } RTCTransportProtocol::~RTCTransportProtocol() {} -int RTCTransportProtocol::start() { - if (is_running_) return -1; - - reset(); - is_first_ = true; - - probeRtt(); - sentinelTimer(); - newRound(); - - return TransportProtocol::start(); -} - void RTCTransportProtocol::resume() { if (is_running_) return; @@ -72,7 +59,7 @@ void RTCTransportProtocol::resume() { } // private -void RTCTransportProtocol::reset() { +void RTCTransportProtocol::initParams() { portal_->setConsumerCallback(this); // controller var currentState_ = HICN_RTC_SYNC_STATE; @@ -125,7 +112,14 @@ void RTCTransportProtocol::reset() { socket_->setSocketOption(GeneralTransportOptions::INTEREST_LIFETIME, (uint32_t)HICN_RTC_INTEREST_LIFETIME); - // XXX this should be done by the application +} + +// private +void RTCTransportProtocol::reset() { + initParams(); + probeRtt(); + sentinelTimer(); + newRound(); } uint32_t max(uint32_t a, uint32_t b) { diff --git a/libtransport/src/protocols/rtc.h b/libtransport/src/protocols/rtc.h index a12c96b69..9f1bcc25b 100644 --- a/libtransport/src/protocols/rtc.h +++ b/libtransport/src/protocols/rtc.h @@ -93,7 +93,7 @@ class RTCTransportProtocol : public TransportProtocol, ~RTCTransportProtocol(); - int start() override; + using TransportProtocol::start; using TransportProtocol::stop; @@ -103,6 +103,7 @@ class RTCTransportProtocol : public TransportProtocol, private: // algo functions + void initParams(); void reset() override; // CC functions |