mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
finished support for multiple destination nodes
This commit is contained in:
parent
980f1d12fa
commit
b6fce3fe8d
2 changed files with 21 additions and 11 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <pthread.h>
|
||||
#include <libconfig.h>
|
||||
|
||||
#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;
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue