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.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/tools/ocbr/ocbr_server.c b/src/tools/ocbr/ocbr_server.c
index 3fb06225..c98b33e9 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 - 2026
*
* 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
@@ -114,14 +114,14 @@ static void handle_flow(int fd)
bytes_read += count;
}
- if (ts_diff_us(&alive, &now)
+ if (ts_diff_us(&now, &alive)
> server_settings.timeout * MILLION) {
printf("Test on flow %d timed out\n", fd);
stop = true;
}
- if (stop || ts_diff_ms(&now, &iv_end) < 0) {
- long us = ts_diff_us(&iv_start, &now);
+ if (stop || ts_diff_ms(&now, &iv_end) > 0) {
+ long us = ts_diff_us(&now, &iv_start);
printf("Flow %4d: %9ld packets (%12ld bytes) in %9ld ms"
" => %9.4f pps, %9.4f Mbps\n",
fd,
@@ -142,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;
@@ -150,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);
@@ -184,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");