The oping and ocbr servers were using non-blocking read/writes. This
caused writes to fail on high-performance tests if the buffer got
full, instead of waiting for a slot in the buffer. The write failure
caused the server to quit. This fixes the tools by setting the I/O to
blocking write and non-blocking read.
Signed-off-by: Dimitri Staessens <dimitri.staessens@xxxxxxxx>
---
src/tools/ocbr/ocbr_server.c | 9 +++++----
src/tools/oping/oping_server.c | 2 +-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/tools/ocbr/ocbr_server.c b/src/tools/ocbr/ocbr_server.c
index 874155e..f24a34b 100644
--- a/src/tools/ocbr/ocbr_server.c
+++ b/src/tools/ocbr/ocbr_server.c
@@ -100,22 +100,23 @@ static void handle_flow(int fd)
alive = iv_start;
ts_add(&iv_start, &intv, &iv_end);
- fccntl(fd, FLOWSFLAGS, FLOWFNONBLOCK);
+ fccntl(fd, FLOWSFLAGS, FLOWFRNOBLOCK);
while (!stop) {
clock_gettime(CLOCK_REALTIME, &now);
count = flow_read(fd, buf, BUF_SIZE);
-
if (count > 0) {
clock_gettime(CLOCK_REALTIME, &alive);
sdus++;
bytes_read += count;
}
- if (ts_diff_us(&alive, &now)
- > server_settings.timeout * MILLION) {
+ if (ts_diff_us(&alive, &now) >
+ server_settings.timeout * MILLION) {
printf("Test on flow %d timed out\n", fd);
+ printf("Time now is %zd. active %zd\n.",
+ now.tv_sec, alive.tv_sec);
stop = true;
}
diff --git a/src/tools/oping/oping_server.c b/src/tools/oping/oping_server.c
index e91b6f1..391da19 100644
--- a/src/tools/oping/oping_server.c
+++ b/src/tools/oping/oping_server.c
@@ -142,7 +142,7 @@ void * accept_thread(void * o)
server.times[fd] = now;
pthread_mutex_unlock(&server.lock);
- fccntl(fd, FLOWSFLAGS, FLOWFNONBLOCK | FLOWFRDWR);
+ fccntl(fd, FLOWSFLAGS, FLOWFRNOBLOCK | FLOWFRDWR);
}
return (void *) 0;
--
2.16.2