summaryrefslogtreecommitdiff
path: root/src/tools/oping/oping_server.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-03-30 20:33:22 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-03-31 11:51:33 +0200
commit7ba0fd0ce19244745c8d2512ce8a003783d914a7 (patch)
treee33ed7dae832ef96cd1997ec038764fac5d95d4c /src/tools/oping/oping_server.c
parentbce97d70ce43290f8351f34c763b30bfd73e6b99 (diff)
downloadouroboros-7ba0fd0ce19244745c8d2512ce8a003783d914a7.tar.gz
ouroboros-7ba0fd0ce19244745c8d2512ce8a003783d914a7.zip
lib: Revise flow allocation API
The flow_alloc_res and flow_alloc_resp calls have been removed. The flow_alloc and flow_accept calls are now both blocking and take an additional timeout argument.
Diffstat (limited to 'src/tools/oping/oping_server.c')
-rw-r--r--src/tools/oping/oping_server.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/tools/oping/oping_server.c b/src/tools/oping/oping_server.c
index e20e236d..44a301ba 100644
--- a/src/tools/oping/oping_server.c
+++ b/src/tools/oping/oping_server.c
@@ -57,6 +57,7 @@ void * cleaner_thread(void * o)
for (i = 0; i < OPING_MAX_FLOWS; ++i)
if (flow_set_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);
flow_dealloc(i);
}
@@ -110,8 +111,8 @@ void * server_thread(void *o)
void * accept_thread(void * o)
{
- int fd = 0;
- struct timespec now = {0, 0};
+ int fd;
+ struct timespec now;
qosspec_t qs;
(void) o;
@@ -119,7 +120,7 @@ void * accept_thread(void * o)
printf("Ouroboros ping server started.\n");
while (true) {
- fd = flow_accept(&qs);
+ fd = flow_accept(&qs, NULL);
if (fd < 0) {
printf("Failed to accept flow.\n");
break;
@@ -127,12 +128,6 @@ void * accept_thread(void * o)
printf("New flow %d.\n", fd);
- if (flow_alloc_resp(fd, 0)) {
- printf("Failed to give an allocate response.\n");
- flow_dealloc(fd);
- continue;
- }
-
clock_gettime(CLOCK_REALTIME, &now);
pthread_mutex_lock(&server.lock);