diff --git a/include/pool.h b/include/pool.h index 6bb00b951..d396921ee 100644 --- a/include/pool.h +++ b/include/pool.h @@ -17,10 +17,10 @@ #define pool_end(pool) pool_get(pool, pool->lenght) /** Return pointer to last element which has been inserted. */ -#define pool_current(pool) pool_getrel(pool, 0) +#define pool_current(pool) pool_getrel(pool, -1) /** Return pointer to the element before the previously added one. */ -#define pool_previous(pool) pool_getrel(pool, -1) +#define pool_previous(pool) pool_getrel(pool, -2) /** Iterate through the circuluar buffer. */ #define pool_foreach(ptr, pool, start, end) for (int _i = start, _p; _p = 1, _i < end; _i++) \ diff --git a/lib/path.c b/lib/path.c index 88066ea05..e122cc438 100644 --- a/lib/path.c +++ b/lib/path.c @@ -89,9 +89,6 @@ static void * path_run(void *arg) error("Failed to receive message from node %s", node_name(p->in)); else if (recv == 0) continue; - - /* Update tail pointer of message pool by the amount of actually received messages. */ - pool_push(&p->pool, recv); /** @todo Replace this timestamp by hardware timestamping for node type which support it. */ p->ts.last = p->ts.recv; @@ -107,6 +104,9 @@ static void * path_run(void *arg) /* For each received message... */ for (int i = 0; i < recv; i++) { + /* Update tail pointer of message pool by the amount of actually received messages. */ + pool_push(&p->pool, 1); + p->received++; /* Run hooks for filtering, stats collection and manipulation */