summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2023-11-07 18:14:11 +0100
committerSander Vrijders <sander@ouroboros.rocks>2023-11-08 09:17:53 +0100
commitd7e3ef70b601831d5bef3fef21fa16b761f561e8 (patch)
treeb091e8a7acdb95eaf38aa7aadbb22fe87836f8ff
parente8d7815033a0a9079be9b8ddefd496043f3f5dee (diff)
downloadouroboros-d7e3ef70b601831d5bef3fef21fa16b761f561e8.tar.gz
ouroboros-d7e3ef70b601831d5bef3fef21fa16b761f561e8.zip
lib: Fix timeout overflow on 32-bit systems0.20.1
The timeout comparison for keepalives could overflow on 32-bit systems, as times were converted to nanoseconds and be limited to a bit over 4 seconds. This caused flow reads to fail miserably with EFLOWPEER errors when keepalives were set higher on these systems. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/lib/dev.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 75645319..aa134283 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,7 +9,7 @@ include(GNUInstallDirs)
set(PACKAGE_VERSION_MAJOR 0)
set(PACKAGE_VERSION_MINOR 20)
-set(PACKAGE_VERSION_PATCH 0)
+set(PACKAGE_VERSION_PATCH 1)
set(PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
set(PACKAGE_DESCRIPTION "The Ouroboros prototype")
diff --git a/src/lib/dev.c b/src/lib/dev.c
index 55fc3575..8e9a2e7e 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -315,13 +315,13 @@ static void _flow_keepalive(struct flow * flow)
clock_gettime(PTHREAD_COND_CLOCK, &now);
- if (ts_diff_ns(&r_act, &now) > timeo * MILLION) {
+ if (ts_diff_ns(&r_act, &now) > (int64_t) timeo * MILLION) {
shm_rbuff_set_acl(flow->rx_rb, ACL_FLOWPEER);
shm_flow_set_notify(ai.fqset, flow_id, FLOW_PEER);
return;
}
- if (ts_diff_ns(&s_act, &now) > (timeo * MILLION) >> 2) {
+ if (ts_diff_ns(&s_act, &now) > (int64_t) timeo * (MILLION >> 2)) {
pthread_rwlock_unlock(&ai.lock);
flow_send_keepalive(flow, now);