[MESHLINK_ERROR] = "\x1b[31mERROR",
[MESHLINK_CRITICAL] = "\x1b[31mCRITICAL",
};
- fprintf(stderr, "%s\t%s:\x1b[0m %s\n", mesh->name,levelstr[level], text);
+ fprintf(stderr, "%s\t%s:\x1b[0m %s\n", mesh ? mesh->name : "global",levelstr[level], text);
}
//Test mesh sending data
printf("%zu known nodes:\n", nnodes);
for(int i = 0; i < nnodes; i++) {
//printf(" %s\n", nodes[i]->name);
- if (nindex != i) {
if(!meshlink_send(mesh[nindex], nodes[i], "magic", strlen("magic") + 1)) {
fprintf(stderr, "Could not send message to '%s': %s\n", nodes[i]->name, meshlink_strerror(meshlink_errno));
}
- }
}
}
mesh = calloc(n, sizeof *mesh);
- meshlink_set_log_cb(NULL, MESHLINK_DEBUG, log_message);
+ meshlink_set_log_cb(NULL, MESHLINK_INFO, log_message);
mkdir(basebase, 0750);
char filename[PATH_MAX];
*/
static void timeout_handler(event_loop_t *loop, void *data) {
meshlink_handle_t *mesh = loop->data;
+ logger(mesh, MESHLINK_DEBUG, "timeout_handler()");
for list_each(connection_t, c, mesh->connections) {
+ // Also make sure that if outstanding key requests for the UDP counterpart of a connection has timed out, we restart it.
+ if(c->node) {
+ if(c->node->status.waitingforkey && c->node->last_req_key + mesh->pingtimeout <= mesh->loop.now.tv_sec)
+ send_req_key(mesh, c->node);
+ }
if(c->last_ping_time + mesh->pingtimeout <= mesh->loop.now.tv_sec) {
if(c->status.active) {
if(c->status.pinged) {