From b103212a0296ad57a6cf46ecc84790cd4cfefcab Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 10 Jun 2015 15:13:02 +0200 Subject: [PATCH] cleanups --- server/include/path.h | 4 +++- server/src/path.c | 32 +++++++++++++++----------------- server/src/socket.c | 1 - 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/server/include/path.h b/server/include/path.h index 71b0d64e0..eb4d65728 100644 --- a/server/include/path.h +++ b/server/include/path.h @@ -62,9 +62,11 @@ struct path /* The following fields are mostly managed by hook_ functions */ /** Histogram of sequence number displacement of received messages */ - struct hist hist_seq; + struct hist hist_sequence; /** Histogram for delay of received messages */ struct hist hist_delay; + /** Histogram for inter message delay (time between received messages) */ + struct hist hist_gap; /** Last message received */ struct timespec ts_recv; diff --git a/server/src/path.c b/server/src/path.c index 54d951f2c..aac0b3750 100644 --- a/server/src/path.c +++ b/server/src/path.c @@ -11,7 +11,6 @@ #include "utils.h" #include "path.h" -#include "socket.h" #include "timing.h" #include "config.h" #include "stats.h" @@ -44,17 +43,6 @@ static void path_write(struct path *p) static void * path_run_async(void *arg) { struct path *p = arg; - struct itimerspec its = { - .it_interval = time_from_double(1 / p->rate), - .it_value = { 1, 0 } - }; - - p->tfd = timerfd_create(CLOCK_REALTIME, 0); - if (p->tfd < 0) - serror("Failed to create timer"); - - if (timerfd_settime(p->tfd, 0, &its, NULL)) - serror("Failed to start timer"); /* Block until 1/p->rate seconds elapsed */ while (timerfd_wait(p->tfd)) @@ -93,9 +81,6 @@ static void * path_run(void *arg) p->previous = &p->pool[(p->received-1) % p->poolsize]; p->current = &p->pool[ p->received % p->poolsize]; - if (settings.debug >= 10) - msg_fprint(stdout, p->current); - p->received++; /* Run hooks for filtering, stats collection and manipulation */ @@ -130,8 +115,21 @@ int path_start(struct path *p) return -1; /* At fixed rate mode, we start another thread for sending */ - if (p->rate) + if (p->rate) { + struct itimerspec its = { + .it_interval = time_from_double(1 / p->rate), + .it_value = { 1, 0 } + }; + + p->tfd = timerfd_create(CLOCK_REALTIME, 0); + if (p->tfd < 0) + serror("Failed to create timer"); + + if (timerfd_settime(p->tfd, 0, &its, NULL)) + serror("Failed to start timer"); + pthread_create(&p->sent_tid, NULL, &path_run_async, p); + } return pthread_create(&p->recv_tid, NULL, &path_run, p); } @@ -142,7 +140,7 @@ int path_stop(struct path *p) path_print(p, buf, sizeof(buf)); info("Stopping path: %s", buf); - + pthread_cancel(p->recv_tid); pthread_join(p->recv_tid, NULL); diff --git a/server/src/socket.c b/server/src/socket.c index 981e84319..66d54f503 100644 --- a/server/src/socket.c +++ b/server/src/socket.c @@ -59,7 +59,6 @@ int socket_init(int argc, char * argv[], struct settings *set) i = if_create(index); list_push(&i->sockets, s); - i->refcnt++; } FOREACH(&interfaces, it)