diff --git a/server/include/path.h b/server/include/path.h index 5867c6cc9..78bc4432f 100644 --- a/server/include/path.h +++ b/server/include/path.h @@ -11,6 +11,7 @@ #include #include +#include "list.h" #include "config.h" #include "hist.h" #include "node.h" @@ -25,11 +26,14 @@ struct path { /** Pointer to the incoming node */ struct node *in; - /** Pointer to the outgoing node */ + /** Pointer to the first outgoing node. + * Usually this is only a pointer to the first list element of path::destinations. */ struct node *out; - - /** Function pointer of the hook */ - hook_cb_t hook; + + /** List of all outgoing nodes */ + struct list destinations; + /** List of function pointers to hooks */ + struct list hooks; /** Send messages with a fixed rate over this path */ double rate; @@ -43,7 +47,7 @@ struct path /** Last known message number */ unsigned int sequence; - /** Counter for sent messages to all outgoing nodes*/ + /** Counter for sent messages to all outgoing nodes */ unsigned int sent; /** Counter for received messages from all incoming nodes */ unsigned int received; diff --git a/server/src/path.c b/server/src/path.c index 347154fa9..264d005b1 100644 --- a/server/src/path.c +++ b/server/src/path.c @@ -21,7 +21,7 @@ /** Linked list of paths */ struct path *paths; -/** Send messages */ +/** Send messages asynchronously */ static void * path_send(void *arg) { int sig; @@ -53,9 +53,12 @@ static void * path_send(void *arg) while (1) { sigwait(&set, &sig); /* blocking wait for next timer tick */ - if (p->last) { - node_write(p->out, p->last); - p->last = NULL; + + if (p->received) { + FOREACH(&p->destinations, it) { + node_write(it->node, p->last); + } + p->sent++; } } @@ -74,7 +77,7 @@ static void * path_run(void *arg) /* Open deferred TCP connection */ node_start_defer(p->in); - node_start_defer(p->out); + // FIXME: node_start_defer(p->out); /* Main thread loop */ while (1) { @@ -131,7 +134,10 @@ static void * path_run(void *arg) /* At fixed rate mode, messages are send by another thread */ if (!p->rate) { - node_write(p->out, m); /* Send message */ + FOREACH(&p->destinations, it) { + node_write(it->node, m); + } + p->sent++; } }