if(c->edge) {
if(report)
- send_del_edge(mesh->everyone, c->edge);
+ send_del_edge(mesh, mesh->everyone, c->edge);
- edge_del(c->edge);
+ edge_del(mesh, c->edge);
c->edge = NULL;
/* Run MST and SSSP algorithms */
- graph();
+ graph(mesh);
/* If the node is not reachable anymore but we remember it had an edge to us, clean it up */
edge_t *e;
e = lookup_edge(c->node, mesh->self);
if(e) {
- send_del_edge(mesh->everyone, e);
- edge_del(e);
+ send_del_edge(mesh, mesh->everyone, e);
+ edge_del(mesh, e);
}
}
}
outgoing_t *outgoing = c->outgoing;
- connection_del(c);
+ connection_del(mesh, c);
/* Check if this was our outgoing connection */
if(c->status.pinged) {
logger(DEBUG_CONNECTIONS, LOG_INFO, "%s (%s) didn't respond to PING in %ld seconds", c->name, c->hostname, (long)mesh->loop.now.tv_sec - c->last_ping_time);
} else if(c->last_ping_time + mesh->pinginterval <= mesh->loop.now.tv_sec) {
- send_ping(c);
+ send_ping(mesh, c);
continue;
} else {
continue;
}
if(!found) {
+ //TODO: if the node is blacklisted the connection will not happen, but
+ //the user will read this debug message "Autoconnecting to %s" that is misleading
logger(DEBUG_CONNECTIONS, LOG_INFO, "Autoconnecting to %s", n->name);
outgoing_t *outgoing = xzalloc(sizeof *outgoing);
outgoing->name = xstrdup(n->name);
}
void handle_meta_connection_data(meshlink_handle_t *mesh, connection_t *c) {
- if (!receive_meta(c)) {
+ if (!receive_meta(mesh, c)) {
terminate_connection(mesh, c, c->status.active);
return;
}
timeout_add(&mesh->loop, &mesh->pingtimer, timeout_handler, &mesh->pingtimer, &(struct timeval){mesh->pingtimeout, rand() % 100000});
timeout_add(&mesh->loop, &mesh->periodictimer, periodic_handler, &mesh->periodictimer, &(struct timeval){mesh->pingtimeout, rand() % 100000});
+ //Add signal handler
+ mesh->datafromapp.signum = 0;
+ signal_add(&(mesh->loop),&(mesh->datafromapp), (signal_cb_t)meshlink_send_from_queue,mesh, mesh->datafromapp.signum);
+
if(!event_loop_run(&mesh->loop)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Error while waiting for input: %s", strerror(errno));
return 1;