mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-07-14 19:16:59 +00:00
FS-9775: Format sources
This commit is contained in:
parent
eac02b764b
commit
1aee27863f
@ -431,12 +431,6 @@ ks_status_t ks_dhtrt_insert_node(ks_dhtrt_routetable_t *table, ks_dht_node_t *no
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
todo: attempting a ping at at this point would require us
|
||||
to suspend this process ... tricky...assume right now we will go ahead and
|
||||
eject. Possibly add to a list to recheck
|
||||
*/
|
||||
|
||||
if ( !(header->flags & BHF_LEFT) ) { /* only the left handside node can be split */
|
||||
#ifdef KS_DHT_DEBUGPRINTF_
|
||||
char bufx[100];
|
||||
@ -493,7 +487,8 @@ ks_status_t ks_dhtrt_insert_node(ks_dhtrt_routetable_t *table, ks_dht_node_t *no
|
||||
ks_rwl_write_lock(bucket->lock); /* lock new bucket */
|
||||
ks_rwl_write_unlock(header->right->bucket->lock); /* unlock old bucket */
|
||||
header = newleft;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bucket = newright->bucket;
|
||||
/* note: we still hold a lock on the bucket */
|
||||
header = newright;
|
||||
@ -1162,7 +1157,9 @@ ks_dhtrt_bucket_header_t *ks_dhtrt_create_bucketheader(ks_pool_t *pool, ks_dhtrt
|
||||
#ifdef KS_DHT_DEBUGPRINTF_
|
||||
char buffer[100];
|
||||
ks_log(KS_LOG_DEBUG, "creating bucket header for mask: %s\n", ks_dhtrt_printableid(mask, buffer));
|
||||
if (parent) ks_log(KS_LOG_DEBUG, " ... from parent mask: %s\n", ks_dhtrt_printableid(parent->mask, buffer));
|
||||
if (parent) {
|
||||
ks_log(KS_LOG_DEBUG, " ... from parent mask: %s\n", ks_dhtrt_printableid(parent->mask, buffer));
|
||||
}
|
||||
#endif
|
||||
return header;
|
||||
}
|
||||
@ -1221,7 +1218,6 @@ ks_dhtrt_bucket_header_t *ks_dhtrt_find_relatedbucketheader(ks_dhtrt_bucket_head
|
||||
header = header->right;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1537,7 +1533,6 @@ uint8_t ks_dhtrt_load_query(ks_dhtrt_querynodes_t *query, ks_dhtrt_sortedxors_t
|
||||
char buf1[100];
|
||||
ks_log(KS_LOG_DEBUG, "load_query: UNLOCKING bucket %s\n",
|
||||
ks_dhtrt_printableid(current->bheader->mask, buf1));
|
||||
fflush(stdout);
|
||||
#endif
|
||||
ks_rwl_read_unlock(current->bheader->bucket->lock); /* release the read lock from findclosest_bucketnodes */
|
||||
|
||||
|
@ -28,7 +28,7 @@ int doquery(ks_dhtrt_routetable_t* rt, uint8_t* id, enum ks_dht_nodetype_t type,
|
||||
|
||||
void test01()
|
||||
{
|
||||
printf("*** testbuckets - test01 start\n"); fflush(stdout);
|
||||
printf("**** testbuckets - test01 start\n"); fflush(stdout);
|
||||
|
||||
ks_dhtrt_routetable_t *rt;
|
||||
ks_dhtrt_initroute(&rt, dht, pool, tpool);
|
||||
@ -59,26 +59,26 @@ void test01()
|
||||
|
||||
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");
|
||||
printf("**** ks_dhtrt_create_node test01 did allow duplicate createnodes!!\n");
|
||||
exit(103);
|
||||
}
|
||||
if (peer != peer1) {
|
||||
printf("*** ks_dhtrt_create_node duplicate createnode did not return the same node!\n");
|
||||
printf("**** ks_dhtrt_create_node duplicate createnode did not return the same node!\n");
|
||||
exit(104);
|
||||
}
|
||||
|
||||
status = ks_dhtrt_delete_node(rt, peer);
|
||||
if (status == KS_STATUS_FAIL) {
|
||||
printf("*** ks_dhtrt_delete_node test01 failed\n");
|
||||
printf("**** ks_dhtrt_delete_node test01 failed\n");
|
||||
exit(104);
|
||||
}
|
||||
|
||||
printf("*** testbuckets - test01 complete\n\n\n"); fflush(stdout);
|
||||
printf("**** testbuckets - test01 complete\n\n\n"); fflush(stdout);
|
||||
}
|
||||
|
||||
void test02()
|
||||
{
|
||||
printf("*** testbuckets - test02 start\n"); fflush(stdout);
|
||||
printf("**** testbuckets - test02 start\n"); fflush(stdout);
|
||||
|
||||
ks_dht_node_t *peer;
|
||||
ks_dht_nodeid_t nodeid;
|
||||
@ -155,9 +155,9 @@ void test02()
|
||||
ks_dhtrt_touch_node(rt, nodeid);
|
||||
|
||||
qcount = doquery(rt, nodeid.id, KS_DHT_BOTH, ifv4);
|
||||
printf("\n*** AF_INET (after touch) count expected 6, actual %d\n", qcount); fflush(stdout);
|
||||
printf("\n**** AF_INET (after touch) count expected 6, actual %d\n", qcount); fflush(stdout);
|
||||
|
||||
printf("*** testbuckets - test02 finished\n"); fflush(stdout);
|
||||
printf("**** testbuckets - test02 finished\n"); fflush(stdout);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -166,7 +166,7 @@ void test02()
|
||||
|
||||
void test03()
|
||||
{
|
||||
printf("*** testbuckets - test03 start\n"); fflush(stdout);
|
||||
printf("**** testbuckets - test03 start\n"); fflush(stdout);
|
||||
|
||||
ks_dht_node_t *peer;
|
||||
ks_dht_nodeid_t nodeid;
|
||||
@ -230,36 +230,36 @@ void test03()
|
||||
|
||||
|
||||
int qcount = doquery(rt, nodeid.id, KS_DHT_LOCAL, both);
|
||||
printf("\n** local query count expected 2, actual %d, max %d\n", qcount, ipv4_local); fflush(stdout);
|
||||
printf("\n**** local query count expected 2, actual %d, max %d\n", qcount, ipv4_local); fflush(stdout);
|
||||
|
||||
qcount = doquery(rt, nodeid.id, KS_DHT_REMOTE, both);
|
||||
printf("\n*** remote query count expected 20, actual %d\n", qcount); fflush(stdout);
|
||||
printf("\n**** remote query count expected 20, actual %d\n", qcount); fflush(stdout);
|
||||
qcount = doquery(rt, nodeid.id, KS_DHT_BOTH, both);
|
||||
printf("\n*** both query count expected 20, actual %d\n", qcount); fflush(stdout);
|
||||
printf("\n**** both query count expected 20, actual %d\n", qcount); fflush(stdout);
|
||||
|
||||
qcount = doquery(rt, nodeid.id, KS_DHT_LOCAL, ifv4);
|
||||
printf("\n*** local AF_INET query count expected 2, actual %d\n", qcount); fflush(stdout);
|
||||
printf("\n**** local AF_INET query count expected 2, actual %d\n", qcount); fflush(stdout);
|
||||
qcount = doquery(rt, nodeid.id, KS_DHT_LOCAL, ifv6);
|
||||
printf("\n*** local AF_INET6 query count expected 0, actual %d\n", qcount); fflush(stdout);
|
||||
printf("\n**** local AF_INET6 query count expected 0, actual %d\n", qcount); fflush(stdout);
|
||||
|
||||
qcount = doquery(rt, nodeid.id, KS_DHT_BOTH, ifv6);
|
||||
printf("\n*** AF_INET6 count expected 20, actual %d\n", qcount); fflush(stdout);
|
||||
printf("\n**** AF_INET6 count expected 20, actual %d\n", qcount); fflush(stdout);
|
||||
|
||||
qcount = doquery(rt, nodeid.id, KS_DHT_REMOTE, ifv4);
|
||||
printf("\n*** remote AF_INET query count expected 20, actual %d max %d\n", qcount, ipv4_remote); fflush(stdout);
|
||||
printf("\n**** remote AF_INET query count expected 20, actual %d max %d\n", qcount, ipv4_remote); fflush(stdout);
|
||||
qcount = doquery(rt, nodeid.id, KS_DHT_REMOTE, ifv6);
|
||||
printf("\n*** remote AF_INET6 query count expected 20, actual %d\n", qcount); fflush(stdout);
|
||||
printf("\n**** remote AF_INET6 query count expected 20, actual %d\n", qcount); fflush(stdout);
|
||||
|
||||
qcount = doquery(rt, nodeid.id, KS_DHT_BOTH, ifv4);
|
||||
printf("\n*** AF_INET count expected 20, actual %d\n", qcount); fflush(stdout);
|
||||
printf("\n**** AF_INET count expected 20, actual %d\n", qcount); fflush(stdout);
|
||||
|
||||
printf("*** testbuckets - test03 finished\n\n\n"); fflush(stdout);
|
||||
printf("**** testbuckets - test03 finished\n\n\n"); fflush(stdout);
|
||||
return;
|
||||
}
|
||||
|
||||
void test04()
|
||||
{
|
||||
printf("*** testbuckets - test04 start\n"); fflush(stdout);
|
||||
printf("**** testbuckets - test04 start\n"); fflush(stdout);
|
||||
|
||||
ks_dht_node_t *peer;
|
||||
ks_dht_nodeid_t nodeid;
|
||||
@ -302,9 +302,9 @@ void test04()
|
||||
int tx = t1 - t0;
|
||||
t1 /= 1000;
|
||||
|
||||
printf("*** query on 10k nodes in %d ms\n", tx);
|
||||
printf("**** query on 10k nodes in %d ms\n", tx);
|
||||
|
||||
printf("*** testbuckets - test04 finished\n\n\n"); fflush(stdout);
|
||||
printf("**** testbuckets - test04 finished\n\n\n"); fflush(stdout);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -312,7 +312,7 @@ void test04()
|
||||
/* test read/write node locking */
|
||||
void test05()
|
||||
{
|
||||
printf("*** testbuckets - test05 start\n"); fflush(stdout);
|
||||
printf("**** testbuckets - test05 start\n"); fflush(stdout);
|
||||
|
||||
ks_dht_node_t *peer, *peer1, *peer2;
|
||||
ks_dht_nodeid_t nodeid;
|
||||
@ -338,8 +338,6 @@ void test05()
|
||||
s = ks_dhtrt_release_node(peer1);
|
||||
if (s == KS_STATUS_FAIL) printf("release 1 failed\n"); fflush(stdout);
|
||||
|
||||
|
||||
|
||||
s = ks_dhtrt_release_node(peer2);
|
||||
if (s == KS_STATUS_FAIL) printf("release 1 failed\n");
|
||||
|
||||
@ -350,7 +348,7 @@ void test05()
|
||||
|
||||
|
||||
/* test06 */
|
||||
/* ------- */
|
||||
/* ------ */
|
||||
ks_dht_nodeid_t g_nodeid1;
|
||||
ks_dht_nodeid_t g_nodeid2;
|
||||
ks_dht_node_t *g_peer;
|
||||
@ -383,7 +381,7 @@ static void *testnodelocking_ex2(ks_thread_t *thread, void *data)
|
||||
|
||||
void test06()
|
||||
{
|
||||
printf("*** testbuckets - test06 start\n"); fflush(stdout);
|
||||
printf("**** testbuckets - test06 start\n"); fflush(stdout);
|
||||
|
||||
ks_dht_node_t *peer;
|
||||
memset(g_nodeid1.id, 0xef, KS_DHT_NODEID_SIZE);
|
||||
@ -420,7 +418,7 @@ void test06()
|
||||
|
||||
ks_dhtrt_process_table(rt);
|
||||
|
||||
printf("*** testbuckets - test06 start\n"); fflush(stdout);
|
||||
printf("**** testbuckets - test06 start\n"); fflush(stdout);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -469,6 +467,7 @@ static void *test60ex2(ks_thread_t *thread, void *data)
|
||||
ks_sleep(2000000);
|
||||
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -552,7 +551,7 @@ void test60()
|
||||
|
||||
void test30()
|
||||
{
|
||||
printf("*** testbuckets - test03 start\n"); fflush(stdout);
|
||||
printf("**** testbuckets - test03 start\n"); fflush(stdout);
|
||||
|
||||
ks_dht_node_t *peer;
|
||||
ks_dht_nodeid_t nodeid;
|
||||
@ -615,13 +614,13 @@ void test30()
|
||||
|
||||
|
||||
int qcount = doquery(rt, nodeid.id, KS_DHT_LOCAL, both);
|
||||
printf("\n** local query count expected 2, actual %d, max %d\n", qcount, ipv4_local); fflush(stdout);
|
||||
printf("\n **** local query count expected 2, actual %d, max %d\n", qcount, ipv4_local); fflush(stdout);
|
||||
|
||||
qcount = doquery(rt, nodeid.id, KS_DHT_LOCAL, both);
|
||||
printf("\n** local query count expected 2, actual %d, max %d\n", qcount, ipv4_local); fflush(stdout);
|
||||
printf("\n **** local query count expected 2, actual %d, max %d\n", qcount, ipv4_local); fflush(stdout);
|
||||
|
||||
qcount = doquery(rt, nodeid.id, KS_DHT_BOTH, both);
|
||||
printf("\n** local query count expected 20, actual %d, max %d\n", qcount, ipv4_local); fflush(stdout);
|
||||
printf("\n **** local query count expected 20, actual %d, max %d\n", qcount, ipv4_local); fflush(stdout);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -711,7 +710,7 @@ void test50()
|
||||
ks_dhtrt_touch_node(rt, nodeid);
|
||||
}
|
||||
|
||||
printf("*** testbuckets - test50 start\n"); fflush(stdout);
|
||||
printf("**** testbuckets - test50 start\n"); fflush(stdout);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -719,7 +718,7 @@ void test50()
|
||||
/* test process_table */
|
||||
void test51()
|
||||
{
|
||||
printf("*** testbuckets - test51 start\n"); fflush(stdout);
|
||||
printf("**** testbuckets - test51 start\n"); fflush(stdout);
|
||||
|
||||
ks_dht_node_t *peer;
|
||||
ks_dht_nodeid_t nodeid, nodeid2;
|
||||
@ -758,8 +757,7 @@ void test51()
|
||||
if ( ix%2 == 0) ks_dhtrt_dump(rt, 7);
|
||||
}
|
||||
|
||||
|
||||
printf("*** testbuckets - test51 complete\n"); fflush(stdout);
|
||||
printf("**** testbuckets - test51 complete\n"); fflush(stdout);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -771,13 +769,12 @@ int main(int argc, char* argv[]) {
|
||||
printf("testdhtbuckets - start\n");
|
||||
|
||||
int tests[100];
|
||||
|
||||
if (argc == 0) {
|
||||
tests[0] = 1;
|
||||
tests[1] = 1;
|
||||
tests[2] = 1;
|
||||
tests[3] = 1;
|
||||
tests[4] = 1;
|
||||
tests[1] = 2;
|
||||
tests[2] = 3;
|
||||
tests[3] = 4;
|
||||
tests[4] = 5;
|
||||
}
|
||||
else {
|
||||
for(int tix=1; tix<100 && tix<argc; ++tix) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user