From f6b898da88e06399aedbfec87296602aef5c09c2 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Tue, 29 Aug 2017 14:30:35 +0200 Subject: dev: Revise fqueue API and add man pages --- src/tools/operf/operf.c | 12 ++++++------ src/tools/operf/operf_server.c | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/tools/operf') diff --git a/src/tools/operf/operf.c b/src/tools/operf/operf.c index e54fbc6b..62adcdb7 100644 --- a/src/tools/operf/operf.c +++ b/src/tools/operf/operf.c @@ -52,13 +52,13 @@ struct c { } client; struct s { - struct timespec times[OPERF_MAX_FLOWS]; - flow_set_t * flows; - fqueue_t * fq; - pthread_mutex_t lock; + struct timespec times[OPERF_MAX_FLOWS]; + fset_t * flows; + fqueue_t * fq; + pthread_mutex_t lock; - uint8_t buffer[OPERF_BUF_SIZE]; - ssize_t timeout; + uint8_t buffer[OPERF_BUF_SIZE]; + ssize_t timeout; pthread_t cleaner_pt; pthread_t accept_pt; diff --git a/src/tools/operf/operf_server.c b/src/tools/operf/operf_server.c index c016ad63..858fbb90 100644 --- a/src/tools/operf/operf_server.c +++ b/src/tools/operf/operf_server.c @@ -50,11 +50,11 @@ void * cleaner_thread(void * o) clock_gettime(CLOCK_REALTIME, &now); pthread_mutex_lock(&server.lock); for (i = 0; i < OPERF_MAX_FLOWS; ++i) - if (flow_set_has(server.flows, i) && + if (fset_has(server.flows, i) && ts_diff_ms(&server.times[i], &now) > server.timeout) { printf("Flow %d timed out.\n", i); - flow_set_del(server.flows, i); + fset_del(server.flows, i); flow_dealloc(i); } @@ -72,7 +72,7 @@ void * server_thread(void *o) (void) o; - while (flow_event_wait(server.flows, server.fq, &timeout)) + while (fevent(server.flows, server.fq, &timeout)) while ((fd = fqueue_next(server.fq)) >= 0) { msg_len = flow_read(fd, server.buffer, OPERF_BUF_SIZE); if (msg_len < 0) @@ -115,7 +115,7 @@ void * accept_thread(void * o) clock_gettime(CLOCK_REALTIME, &now); pthread_mutex_lock(&server.lock); - flow_set_add(server.flows, fd); + fset_add(server.flows, fd); server.times[fd] = now; pthread_mutex_unlock(&server.lock); } @@ -139,13 +139,13 @@ int server_main(void) return -1; } - server.flows = flow_set_create(); + server.flows = fset_create(); if (server.flows == NULL) return 0; server.fq = fqueue_create(); if (server.fq == NULL) { - flow_set_destroy(server.flows); + fset_destroy(server.flows); return -1; } @@ -158,7 +158,7 @@ int server_main(void) pthread_cancel(server.server_pt); pthread_cancel(server.cleaner_pt); - flow_set_destroy(server.flows); + fset_destroy(server.flows); fqueue_destroy(server.fq); pthread_join(server.server_pt, NULL); -- cgit v1.2.3