From 154a118634f6d60116fef1d382478034a3b82e9c Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 16 Nov 2015 11:24:29 +0100 Subject: [PATCH] moved timestamps into separate struct member --- server/include/path.h | 8 +++++--- server/src/hooks.c | 14 +++++++------- server/src/path.c | 6 +++--- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/server/include/path.h b/server/include/path.h index c7b81d60d..e43a0998d 100644 --- a/server/include/path.h +++ b/server/include/path.h @@ -63,9 +63,11 @@ struct path struct hist hist_gap_recv; /**< Histogram for inter message arrival time (as seen by this instance) */ struct hist hist_gap_seq; /**< Histogram of sequence number displacement of received messages */ - struct timespec ts_recv; /**< Last message received */ - struct timespec ts_sent; /**< Last message sent */ - struct timespec ts_last; /**< Previous message received (old value of path::ts_recv) */ + struct { + struct timespec recv; /**< Last message received */ + struct timespec sent; /**< Last message sent */ + struct timespec last; /**< Previous message received (old value of path::ts__recv) */ + } ts; unsigned int sent; /**< Counter for sent messages to all outgoing nodes */ unsigned int received; /**< Counter for received messages from all incoming nodes */ diff --git a/server/src/hooks.c b/server/src/hooks.c index c9dd23177..220f16851 100644 --- a/server/src/hooks.c +++ b/server/src/hooks.c @@ -30,7 +30,7 @@ REGISTER_HOOK("print", 99, hook_print, HOOK_MSG) int hook_print(struct path *p, struct hook *h, int when) { struct msg *m = p->current; - double offset = time_delta(&MSG_TS(m), &p->ts_recv); + double offset = time_delta(&MSG_TS(m), &p->ts.recv); int flags = MSG_PRINT_ALL; /* We dont show the offset if its to large */ @@ -47,8 +47,8 @@ int hook_ts(struct path *p, struct hook *h, int when) { struct msg *m = p->current; - m->ts.sec = p->ts_recv.tv_sec; - m->ts.nsec = p->ts_recv.tv_nsec; + m->ts.sec = p->ts.recv.tv_sec; + m->ts.nsec = p->ts.recv.tv_nsec; return 0; } @@ -262,7 +262,7 @@ int hook_skip_first(struct path *p, struct hook *h, int when) break; case HOOK_PATH_RESTART: - private->started = p->ts_recv; + private->started = p->ts.recv; break; case HOOK_PATH_START: @@ -270,7 +270,7 @@ int hook_skip_first(struct path *p, struct hook *h, int when) break; case HOOK_POST: { - double delta = time_delta(&private->started, &p->ts_recv); + double delta = time_delta(&private->started, &p->ts.recv); return delta < private->wait ? -1 /* skip */ : 0; /* send */ @@ -348,7 +348,7 @@ int hook_stats(struct path *p, struct hook *h, int when) case HOOK_PRE: /* Exclude first message from statistics */ if (p->received > 0) { - double gap = time_delta(&p->ts_last, &p->ts_recv); + double gap = time_delta(&p->ts.last, &p->ts.recv); hist_put(&p->hist_gap_recv, gap); } @@ -359,7 +359,7 @@ int hook_stats(struct path *p, struct hook *h, int when) /* Exclude first message from statistics */ if (p->received > 0) { int dist = cur->sequence - (int32_t) prev->sequence; - double delay = time_delta(&MSG_TS(cur), &p->ts_recv); + double delay = time_delta(&MSG_TS(cur), &p->ts.recv); double gap = time_delta(&MSG_TS(prev), &MSG_TS(cur)); hist_put(&p->hist_gap_msg, gap); diff --git a/server/src/path.c b/server/src/path.c index 7658e621c..d9dd75453 100644 --- a/server/src/path.c +++ b/server/src/path.c @@ -35,7 +35,7 @@ static void path_write(struct path *p) debug(15, "Sent %u messages to node '%s'", sent, n->name); p->sent += sent; - p->ts_sent = time_now(); /** @todo use hardware timestamps for socket node type */ + p->ts.sent = time_now(); /** @todo use hardware timestamps for socket node type */ } } @@ -98,8 +98,8 @@ static void * path_run(void *arg) continue; /** @todo Replace this timestamp by hardware timestamping */ - p->ts_last = p->ts_recv; - p->ts_recv = time_now(); + p->ts.last = p->ts.recv; + p->ts.recv = time_now(); debug(15, "Received %u messages from node '%s'", recv, p->in->name);