summaryrefslogtreecommitdiff
path: root/src/tools/oping
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-08-29 13:11:43 +0000
committerSander Vrijders <sander.vrijders@ugent.be>2017-08-29 13:11:43 +0000
commitda754467efab5194084cd8eeab4a48f89d6b925e (patch)
treef6e8f9e732cc36f4f153e409b3f92cdd7c19dbae /src/tools/oping
parent00aeb6ee00efa98c7e2d6d9bebeb1c4799ba1705 (diff)
parentf6b898da88e06399aedbfec87296602aef5c09c2 (diff)
downloadouroboros-da754467efab5194084cd8eeab4a48f89d6b925e.tar.gz
ouroboros-da754467efab5194084cd8eeab4a48f89d6b925e.zip
Merged in dstaesse/ouroboros/be-fqueue (pull request #574)
dev: Revise fqueue API and add man pages
Diffstat (limited to 'src/tools/oping')
-rw-r--r--src/tools/oping/oping.c8
-rw-r--r--src/tools/oping/oping_server.c15
2 files changed, 11 insertions, 12 deletions
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);