From 632fb36765c2f485b3eb7fec9cdaba24f35e2c15 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Tue, 24 Nov 2020 18:45:34 +0100 Subject: tools: Use read timeouts in ocbr server The ocbr server was using non-blocking reads (probably because we didn't have read timeouts when we wrote it) and was using a whole CPU core per thread. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/tools/ocbr/ocbr_server.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/tools/ocbr') diff --git a/src/tools/ocbr/ocbr_server.c b/src/tools/ocbr/ocbr_server.c index 583f226c..3fb06225 100644 --- a/src/tools/ocbr/ocbr_server.c +++ b/src/tools/ocbr/ocbr_server.c @@ -83,6 +83,7 @@ static void handle_flow(int fd) struct timespec now; struct timespec alive; struct timespec intv = {server_settings.interval, 0}; + struct timespec tic = {0, 100 * MILLION}; struct timespec iv_start; struct timespec iv_end; @@ -99,7 +100,8 @@ static void handle_flow(int fd) alive = iv_start; ts_add(&iv_start, &intv, &iv_end); - fccntl(fd, FLOWSFLAGS, FLOWFRNOBLOCK | FLOWFRDWR | FLOWFRNOPART); + fccntl(fd, FLOWSFLAGS, FLOWFRDWR | FLOWFRNOPART); + fccntl(fd, FLOWSRCVTIMEO, &tic); while (!stop) { clock_gettime(CLOCK_REALTIME, &now); -- cgit v1.2.3