summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/operf/operf.c12
-rw-r--r--src/tools/operf/operf_server.c14
-rw-r--r--src/tools/oping/oping.c8
-rw-r--r--src/tools/oping/oping_server.c15
4 files changed, 24 insertions, 25 deletions
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);
diff --git a/src/tools/oping/oping.c b/src/tools/oping/oping.c
index 13132815..bca4f80b 100644
--- a/src/tools/oping/oping.c
+++ b/src/tools/oping/oping.c
@@ -63,10 +63,10 @@ struct c {
} client;
struct s {
- struct timespec times[OPING_MAX_FLOWS];
- flow_set_t * flows;
- fqueue_t * fq;
- pthread_mutex_t lock;
+ struct timespec times[OPING_MAX_FLOWS];
+ fset_t * flows;
+ fqueue_t * fq;
+ pthread_mutex_t lock;
pthread_t cleaner_pt;
pthread_t accept_pt;
diff --git a/src/tools/oping/oping_server.c b/src/tools/oping/oping_server.c
index 57d1fd7c..6a535caf 100644
--- a/src/tools/oping/oping_server.c
+++ b/src/tools/oping/oping_server.c
@@ -51,10 +51,10 @@ void * cleaner_thread(void * o)
clock_gettime(CLOCK_REALTIME, &now);
pthread_mutex_lock(&server.lock);
for (i = 0; i < OPING_MAX_FLOWS; ++i)
- if (flow_set_has(server.flows, i) &&
+ if (fset_has(server.flows, i) &&
ts_diff_ms(&server.times[i], &now) > deadline_ms) {
printf("Flow %d timed out.\n", i);
- flow_set_del(server.flows, i);
+ fset_del(server.flows, i);
flow_dealloc(i);
}
@@ -75,8 +75,7 @@ void * server_thread(void *o)
(void) o;
while (true) {
- if (flow_event_wait(server.flows, server.fq, &timeout)
- == -ETIMEDOUT)
+ if (fevent(server.flows, server.fq, &timeout) == -ETIMEDOUT)
continue;
while ((fd = fqueue_next(server.fq)) >= 0) {
@@ -127,7 +126,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);
@@ -153,13 +152,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;
}
@@ -172,7 +171,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);