diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-02-22 22:16:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-22 22:16:07 +0100 |
commit | 409fef7ec990e272047596bdee01f952b256786f (patch) | |
tree | 32f1bc28401d3c092c96ab39c50f263fdf2cb0bd | |
parent | affe8053b0b1061af9a84239ec9e625afd7fafe3 (diff) | |
parent | 76a889dc0837a7ccaf3e869ca64b111d4a0ecc70 (diff) |
Merge pull request #21297 from vespa-engine/toregge/handle-higher-resolution-for-steady-clock-duration
Use duration_cast to handle steady clock and system clock having different periods.
-rw-r--r-- | config/src/vespa/config/frt/frtconnection.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/config/src/vespa/config/frt/frtconnection.cpp b/config/src/vespa/config/frt/frtconnection.cpp index 93a5867b180..6eb71eb18f0 100644 --- a/config/src/vespa/config/frt/frtconnection.cpp +++ b/config/src/vespa/config/frt/frtconnection.cpp @@ -79,7 +79,7 @@ void FRTConnection::setSuccess() { _transientFailures = 0; _fatalFailures = 0; - _suspendedUntil = system_time(duration::zero()); + _suspendedUntil = system_time(); } void FRTConnection::calculateSuspension(ErrorType type) @@ -103,7 +103,13 @@ void FRTConnection::calculateSuspension(ErrorType type) break; } system_time now = system_clock::now(); - _suspendedUntil = now + delay; + /* + * On Darwin, the std::chrono::steady_clock period (std::nano) is + * not exactly divisible by the std::chrono::system_clock period + * (std::micro). Thus we need to use std::chrono::duration_cast to + * convert from steady_time::duration to system_time::duration. + */ + _suspendedUntil = now + std::chrono::duration_cast<system_time::duration>(delay); if (_suspendWarned < (now - 5s)) { LOG(warning, "FRT Connection %s suspended until %s", _address.c_str(), vespalib::to_string(_suspendedUntil).c_str()); _suspendWarned = now; |