FS-9775: Exclude newly created nodes from find
This commit is contained in:
parent
f6a2908ea8
commit
4970c7e9a6
|
@ -377,6 +377,11 @@ KS_DECLARE(ks_status_t) ks_dhtrt_delete_node(ks_dhtrt_routetable_t *table, ks_dh
|
|||
ks_rwl_read_unlock(internal->lock); /* release write lock */
|
||||
/* at this point no subsequent find/query will return the node */
|
||||
|
||||
if (s == KS_STATUS_FAIL) {
|
||||
ks_log(KS_LOG_DEBUG, "Delete node: node not found\n");
|
||||
return KS_STATUS_FAIL; /* cannot delete what we cannot find */
|
||||
}
|
||||
|
||||
ks_dhtrt_queue_node_fordelete(table, node);
|
||||
return s;
|
||||
}
|
||||
|
@ -856,11 +861,13 @@ uint8_t ks_dhtrt_findclosest_locked_nodes(ks_dhtrt_routetable_t *table, ks_dhtrt
|
|||
|
||||
KS_DECLARE(ks_status_t) ks_dhtrt_release_node(ks_dht_node_t* node)
|
||||
{
|
||||
assert(node);
|
||||
return ks_rwl_read_unlock(node->reflock);
|
||||
}
|
||||
|
||||
KS_DECLARE(ks_status_t) ks_dhtrt_sharelock_node(ks_dht_node_t* node)
|
||||
{
|
||||
assert(node);
|
||||
return ks_rwl_read_lock(node->reflock);
|
||||
}
|
||||
|
||||
|
@ -1257,9 +1264,7 @@ void ks_dhtrt_split_bucket(ks_dhtrt_bucket_header_t *original,
|
|||
if (ks_dhtrt_ismasked(source->entries[rix].id, left->mask)) {
|
||||
|
||||
/* move it to the left */
|
||||
memcpy(dest->entries[lix].id, source->entries[rix].id, KS_DHT_NODEID_SIZE);
|
||||
dest->entries[lix].gptr = source->entries[rix].gptr;
|
||||
dest->entries[lix].inuse = 1;
|
||||
memcpy(&dest->entries[lix], &source->entries[rix], sizeof(ks_dhtrt_bucket_entry_t));
|
||||
++lix;
|
||||
++dest->count;
|
||||
|
||||
|
@ -1371,7 +1376,8 @@ ks_dht_node_t *ks_dhtrt_find_nodeid(ks_dhtrt_bucket_t *bucket, ks_dhtrt_nodeid_t
|
|||
bucket->entries[ix].inuse );
|
||||
}
|
||||
#endif
|
||||
if ( bucket->entries[ix].inuse == 1 &&
|
||||
if ( bucket->entries[ix].inuse == 1 &&
|
||||
bucket->entries[ix].flags == DHTPEER_ACTIVE &&
|
||||
(!memcmp(id, bucket->entries[ix].id, KS_DHT_NODEID_SIZE)) ) {
|
||||
return bucket->entries[ix].gptr;
|
||||
}
|
||||
|
|
|
@ -52,11 +52,19 @@ void test01()
|
|||
}
|
||||
|
||||
peer = ks_dhtrt_find_node(rt, homeid);
|
||||
if (peer == 0) {
|
||||
printf("*** ks_dhtrt_find_node test01 failed \n"); fflush(stdout);
|
||||
if (peer != 0) {
|
||||
printf("*** ks_dhtrt_find_node test01 failed. find should fail\n"); fflush(stdout);
|
||||
exit(102);
|
||||
}
|
||||
|
||||
ks_dhtrt_touch_node(rt, homeid);
|
||||
|
||||
peer = ks_dhtrt_find_node(rt, homeid);
|
||||
if (peer == 0) {
|
||||
printf("*** ks_dhtrt_find_node test01 failed. find should succeed\n"); fflush(stdout);
|
||||
exit(102);
|
||||
}
|
||||
|
||||
status = ks_dhtrt_create_node(rt, homeid, KS_DHT_LOCAL, ip, port, &peer1);
|
||||
if (status == KS_STATUS_FAIL) {
|
||||
printf("**** ks_dhtrt_create_node test01 did allow duplicate createnodes!!\n");
|
||||
|
@ -325,6 +333,7 @@ void test05()
|
|||
unsigned short port = 7001;
|
||||
|
||||
ks_dhtrt_create_node(rt, nodeid, KS_DHT_REMOTE, ipv4, port, &peer);
|
||||
ks_dhtrt_touch_node(rt, nodeid);
|
||||
|
||||
peer1 = ks_dhtrt_find_node(rt, nodeid);
|
||||
printf("test05 - first find compelete\n"); fflush(stdout);
|
||||
|
@ -341,6 +350,10 @@ void test05()
|
|||
s = ks_dhtrt_release_node(peer2);
|
||||
if (s == KS_STATUS_FAIL) printf("release 1 failed\n");
|
||||
|
||||
s = ks_dhtrt_release_node(peer2);
|
||||
if (s == KS_STATUS_FAIL) printf("release 1 failed\n");
|
||||
|
||||
|
||||
printf("* **testbuckets - test05 finished\n\n\n"); fflush(stdout);
|
||||
|
||||
return;
|
||||
|
@ -440,6 +453,7 @@ void test07()
|
|||
for(int i0=0, i1=0; i0<150; ++i0, ++i1) {
|
||||
if (i0%20 == 0) {
|
||||
g_nodeid2.id[0]>>=1;
|
||||
ks_dhtrt_dump(rt, 7);
|
||||
}
|
||||
else {
|
||||
++ g_nodeid2.id[19];
|
||||
|
@ -449,6 +463,8 @@ void test07()
|
|||
ks_dhtrt_release_node(peer);
|
||||
}
|
||||
|
||||
ks_dhtrt_dump(rt, 7);
|
||||
|
||||
memset(g_nodeid2.id, 0xef, KS_DHT_NODEID_SIZE);
|
||||
for (int i0=0, i1=0; i0<150; ++i0, ++i1) {
|
||||
if (i0%20 == 0) {
|
||||
|
|
Loading…
Reference in New Issue