diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2020-11-24 18:45:34 +0100 |
---|---|---|
committer | Sander Vrijders <sander@ouroboros.rocks> | 2020-11-25 15:35:31 +0100 |
commit | 632fb36765c2f485b3eb7fec9cdaba24f35e2c15 (patch) | |
tree | c45283563c008c7be86dae3507bb6573513385e3 /src/tools/ocbr | |
parent | 4194300ec0af4e268bdb722ba13266352408009c (diff) | |
download | ouroboros-632fb36765c2f485b3eb7fec9cdaba24f35e2c15.tar.gz ouroboros-632fb36765c2f485b3eb7fec9cdaba24f35e2c15.zip |
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 <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/tools/ocbr')
-rw-r--r-- | src/tools/ocbr/ocbr_server.c | 4 |
1 files changed, 3 insertions, 1 deletions
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); |