]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9775: DHT find closest nodes not completing search
authorcolm <colm@freeswitch1>
Fri, 16 Dec 2016 04:51:11 +0000 (23:51 -0500)
committerMike Jerris <mike@jerris.com>
Wed, 25 Jan 2017 20:59:36 +0000 (14:59 -0600)
libs/libks/src/dht/ks_dht_bucket.c

index c64ca228fbc68ee09c00fb52b158e8bed260b46a..468fbc6b887c64e3b1a8678c68a02f426c62c9d5 100644 (file)
@@ -701,15 +701,17 @@ uint8_t ks_dhtrt_findclosest_locked_nodes(ks_dhtrt_routetable_t *table, ks_dhtrt
                        }
                }
           
-               if (!lheader && !rheader) break;
-
+               if (!lheader && !rheader) {
+                       break;
+               }
+       
                ++insanity;
 
                if (insanity > 159) {
                        assert(insanity <= 159);
                }
 
-       } while (max < query->count);
+       } while (max < query->max);
 
 
        ks_dhtrt_load_query(query, &xort0);
@@ -796,7 +798,7 @@ KS_DECLARE(void)  ks_dhtrt_process_table(ks_dhtrt_routetable_t *table)
                                                        }
 
                                                        if (e->flags == DHTPEER_SUSPECT) {
-                                                               ks_dhtrt_ping(e); 
+                                                               ks_dhtrt_ping(e);
                                                                continue;
                                                        }
 
@@ -1217,9 +1219,10 @@ uint8_t ks_dhtrt_findclosest_bucketnodes(ks_dhtrt_nodeid_t id,
 
        for (uint8_t ix=0; ix<KS_DHT_BUCKETSIZE; ++ix) {
 
-           if ( bucket->entries[ix].inuse == 1                              &&
-             (family == ifboth || bucket->entries[ix].family == family)  &&
-             (bucket->entries[ix].type & type)                           &&
+           if ( bucket->entries[ix].inuse == 1                              &&    /* in use      */
+             bucket->entries[ix].flags != DHTPEER_EXPIRED                &&    /* not expired */
+             (family == ifboth || bucket->entries[ix].family == family)  &&    /* match if family */
+             (bucket->entries[ix].type & type)                           &&    /* match type   */
              ks_dhtrt_isactive( &(bucket->entries[ix])) ) {
                  
                        /* calculate xor value */
@@ -1323,6 +1326,8 @@ void ks_dhtrt_ping(ks_dhtrt_bucket_entry_t *entry) {
        /* @todo */
        /* set the appropriate command in the node and queue if for processing */
        /*ks_dht_node_t *node = entry->gptr; */
+       /* ++entry->outstanding_pings; */
+
 #ifdef KS_DHT_DEBUGPRINTF_
        char buf[100];
        printf("  ping queued for nodeid %s count %d\n",