From 55d84600dae30ac5809859f16295444bef7e45ed Mon Sep 17 00:00:00 2001 From: tatiana-kondakova Date: Wed, 7 Mar 2018 12:55:02 +0300 Subject: [PATCH] Adjust TrackingReporter reconnection timeout. Choose enough realTimeBufferSize depending on push delay, reconnect delay, min delay. --- tracking/reporter.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tracking/reporter.cpp b/tracking/reporter.cpp index 3bb5de54b1..0b256e9833 100644 --- a/tracking/reporter.cpp +++ b/tracking/reporter.cpp @@ -1,4 +1,4 @@ -#include "reporter.hpp" +#include "tracking/reporter.hpp" #include "platform/location.hpp" #include "platform/platform.hpp" @@ -11,13 +11,14 @@ #include "std/target_os.hpp" +#include + namespace { double constexpr kRequiredHorizontalAccuracy = 10.0; double constexpr kMinDelaySeconds = 1.0; -double constexpr kReconnectDelaySeconds = 60.0; +double constexpr kReconnectDelaySeconds = 40.0; double constexpr kNotChargingEventPeriod = 5 * 60.0; -size_t constexpr kRealTimeBufferSize = 60; } // namespace namespace tracking @@ -32,9 +33,13 @@ Reporter::Reporter(unique_ptr socket, string const & host, uin : m_allowSendingPoints(true) , m_realtimeSender(move(socket), host, port, false) , m_pushDelay(pushDelay) - , m_points(kRealTimeBufferSize) , m_thread([this] { Run(); }) { + CHECK_NOT_EQUAL(kMinDelaySeconds, 0.0, ()); + // Set buffer size to be enough to keep all points even if one reconnect attempt failed. + auto const realTimeBufferSize = + (duration_cast(m_pushDelay).count() + kReconnectDelaySeconds) / kMinDelaySeconds; + m_points.resize(ceil(realTimeBufferSize)); } Reporter::~Reporter()