summaryrefslogtreecommitdiff
path: root/src/tools/ocbr/ocbr_server.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/ocbr/ocbr_server.c')
-rw-r--r--src/tools/ocbr/ocbr_server.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/tools/ocbr/ocbr_server.c b/src/tools/ocbr/ocbr_server.c
index 583f226c..a4bbadd4 100644
--- a/src/tools/ocbr/ocbr_server.c
+++ b/src/tools/ocbr/ocbr_server.c
@@ -1,10 +1,10 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2020
+ * Ouroboros - Copyright (C) 2016 - 2024
*
* A simple CBR generator
*
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
+ * Dimitri Staessens <dimitri@ouroboros.rocks>
+ * Sander Vrijders <sander@ouroboros.rocks>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -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);
@@ -140,6 +142,11 @@ static void handle_flow(int fd)
flow_dealloc(fd);
}
+static void __cleanup_mutex_unlock(void * mutex)
+{
+ pthread_mutex_unlock((pthread_mutex_t *) mutex);
+}
+
static void * worker(void * o)
{
int cli_fd;
@@ -148,8 +155,7 @@ static void * worker(void * o)
while (true) {
pthread_mutex_lock(&fds_lock);
- pthread_cleanup_push((void(*)(void *)) pthread_mutex_unlock,
- (void *) &fds_lock);
+ pthread_cleanup_push(__cleanup_mutex_unlock, &fds_lock);
while (fds[fds_index] == -1)
pthread_cond_wait(&fds_signal, &fds_lock);
@@ -182,8 +188,7 @@ static void * listener(void * o)
while (true) {
pthread_mutex_lock(&fds_lock);
- pthread_cleanup_push((void(*)(void *)) pthread_mutex_unlock,
- (void *) &fds_lock);
+ pthread_cleanup_push(__cleanup_mutex_unlock, &fds_lock);
while (fds_count == THREADS_SIZE) {
printf("Can't accept any more flows, waiting.\n");