aboutsummaryrefslogtreecommitdiffstats
path: root/fnet
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-11-05 12:48:15 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-11-05 12:48:15 +0000
commit9caad60522047a21974b759380f485f85602cf74 (patch)
tree000ba8400632c5d7a701163194d4fa68c1e8f95a /fnet
parenta65780d57302eaf5a5791068e233f781e35d4401 (diff)
Guard against timeout value that is too high and will cause overflow.
Diffstat (limited to 'fnet')
-rw-r--r--fnet/src/vespa/fnet/frt/supervisor.cpp3
-rw-r--r--fnet/src/vespa/fnet/scheduler.cpp2
2 files changed, 4 insertions, 1 deletions
diff --git a/fnet/src/vespa/fnet/frt/supervisor.cpp b/fnet/src/vespa/fnet/frt/supervisor.cpp
index a8cb7884534..7e92855583e 100644
--- a/fnet/src/vespa/fnet/frt/supervisor.cpp
+++ b/fnet/src/vespa/fnet/frt/supervisor.cpp
@@ -157,7 +157,8 @@ FRT_Supervisor::InvokeAsync(SchedulerPtr scheduler, FNET_Connection *conn, FRT_R
adapter->ScheduleNow();
return;
}
- if (timeout > 0.0) {
+ constexpr double ONE_YEAR_S = 3600*24*365;
+ if (timeout > 0.0 && timeout < ONE_YEAR_S) {
adapter->Schedule(timeout);
}
conn->PostPacket(packet, chid);
diff --git a/fnet/src/vespa/fnet/scheduler.cpp b/fnet/src/vespa/fnet/scheduler.cpp
index d37b5487162..a4d504db752 100644
--- a/fnet/src/vespa/fnet/scheduler.cpp
+++ b/fnet/src/vespa/fnet/scheduler.cpp
@@ -69,6 +69,8 @@ FNET_Scheduler::~FNET_Scheduler()
void
FNET_Scheduler::Schedule(FNET_Task *task, double seconds)
{
+ constexpr double ONE_MONTH_S = 3600 * 24 * 30;
+ seconds = std::min(seconds, ONE_MONTH_S);
uint32_t ticks = 2 + (uint32_t) std::ceil(seconds * (1000.0 / tick_ms.count()));
std::lock_guard<std::mutex> guard(_lock);