summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2020-11-24 18:45:34 +0100
committerSander Vrijders <[email protected]>2020-11-25 15:35:31 +0100
commit632fb36765c2f485b3eb7fec9cdaba24f35e2c15 (patch)
treec45283563c008c7be86dae3507bb6573513385e3 /src
parent4194300ec0af4e268bdb722ba13266352408009c (diff)
downloadouroboros-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 <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/tools/ocbr/ocbr_server.c4
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);