]> git.meshlink.io Git - meshlink/commitdiff
Merge branch 'everbase' into roles
authorNiklas Hofmann <niklas.hofmann@everbase.net>
Sat, 9 Aug 2014 14:35:26 +0000 (16:35 +0200)
committerNiklas Hofmann <niklas.hofmann@everbase.net>
Sat, 9 Aug 2014 14:35:26 +0000 (16:35 +0200)
examples/manynodes.c
src/net.c

index e00b80beeec203039fec0a353a65e827a62c2f5a..96aa5f0f9843db84bb7c4bc7481a285965fa6491 100644 (file)
@@ -22,7 +22,7 @@ static void log_message(meshlink_handle_t *mesh, meshlink_log_level_t level, con
                [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
@@ -37,11 +37,9 @@ static void testmesh () {
                                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));
                                                }
-                                       }
                                }
 
                        }
@@ -234,7 +232,7 @@ int main(int argc, char *argv[]) {
 
        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];
index 9d48a283f368e3346dcef49762e51b7540cab029..4045c136fa676912ac42110e6eb0920974cf8650 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -98,8 +98,14 @@ void terminate_connection(meshlink_handle_t *mesh, connection_t *c, bool report)
 */
 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) {