]> git.meshlink.io Git - meshlink/commitdiff
Make retry outgoing logic instantaneously connect when a change is discovered on...
authorlakshminarayanagurram <lakshminarayana@elear.solutions>
Fri, 24 May 2019 01:20:07 +0000 (06:50 +0530)
committerGuus Sliepen <guus@meshlink.io>
Wed, 5 Jun 2019 18:51:22 +0000 (20:51 +0200)
src/discovery.c

index e7ac94ee64cec97eb596acb4efa0cf6fc5326579..4aa34d434ef0d5a687857a17786c9c27f438ba89 100644 (file)
@@ -11,6 +11,8 @@
 #include "discovery.h"
 #include "sockaddr.h"
 #include "logger.h"
+#include "node.h"
+#include "connection.h"
 
 #include <pthread.h>
 
@@ -266,6 +268,23 @@ static void discovery_resolve_callback(CattaSServiceResolver *resolver, CattaIfI
 
                                        if(naddress.unknown.family != AF_UNKNOWN) {
                                                meshlink_hint_address(mesh, (meshlink_node_t *)node, (struct sockaddr *)&naddress);
+                                               pthread_mutex_lock(&(mesh->mesh_mutex));
+
+                                               node_t *n = (node_t *)node;
+
+                                               if(n->connection && n->connection->outgoing) {
+                                                       n->connection->outgoing->timeout = 0;
+
+                                                       if(n->connection->outgoing->ev.cb) {
+                                                               timeout_set(&mesh->loop, &n->connection->outgoing->ev, &(struct timeval) {
+                                                                       0, 0
+                                                               });
+                                                       }
+
+                                                       n->connection->last_ping_time = 0;
+                                               }
+
+                                               pthread_mutex_unlock(&(mesh->mesh_mutex));
                                        } else {
                                                logger(mesh, MESHLINK_WARNING, "Could not resolve node %s to a known address family type.\n", node->name);
                                        }