From 9b6fdc1c2abe85008610063d800edf80e5011a4d Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sat, 10 Mar 2018 11:53:31 +0100 Subject: lib: Use PTHREAD_COND_CLOCK for blocking reads The rbuff uses the PTHREAD_COND_CLOCK for its condition variables, but the flow_read was passing a time it got from the CLOCK_REALTIME_COARSE clock. This causes the blocking reads not to timeout correctly. The oping was updated to detect server timeouts and finish gracefully. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/tools/oping/oping_client.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/tools/oping') diff --git a/src/tools/oping/oping_client.c b/src/tools/oping/oping_client.c index dbbbfa19..6f874dd9 100644 --- a/src/tools/oping/oping_client.c +++ b/src/tools/oping/oping_client.c @@ -55,7 +55,7 @@ void shutdown_client(int signo, siginfo_t * info, void * c) void * reader(void * o) { - struct timespec timeout = {2, 0}; + struct timespec timeout = {client.interval / 1000 + 2, 0}; struct timespec now = {0, 0}; struct timespec sent; @@ -70,8 +70,11 @@ void * reader(void * o) while (!stop && client.rcvd != client.count) { msg_len = flow_read(fd, buf, OPING_BUF_SIZE); - if (msg_len == -ETIMEDOUT) + if (msg_len == -ETIMEDOUT) { + printf("Server timed out.\n"); + stop = true; break; + } if (msg_len < 0) continue; -- cgit v1.2.3