summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri.staessens@ugent.be>2018-03-10 11:53:31 +0100
committerSander Vrijders <sander.vrijders@ugent.be>2018-03-10 13:01:23 +0100
commit9b6fdc1c2abe85008610063d800edf80e5011a4d (patch)
tree987604180db1a56e31dd7deb8c1f624951b0431a /src
parentd90f7f88d0c8cf3f96c10896f4c6fa4f6a138bf0 (diff)
downloadouroboros-9b6fdc1c2abe85008610063d800edf80e5011a4d.tar.gz
ouroboros-9b6fdc1c2abe85008610063d800edf80e5011a4d.zip
lib: Use PTHREAD_COND_CLOCK for blocking reads0.10.6
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 <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
Diffstat (limited to 'src')
-rw-r--r--src/lib/dev.c2
-rw-r--r--src/tools/oping/oping_client.c7
2 files changed, 6 insertions, 3 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index 7e829a5f..2e128d59 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -890,7 +890,7 @@ ssize_t flow_read(int fd,
flow = &ai.flows[fd];
- clock_gettime(CLOCK_REALTIME_COARSE, &now);
+ clock_gettime(PTHREAD_COND_CLOCK, &now);
pthread_rwlock_rdlock(&ai.lock);
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;