FS-9775: Add ks_dhtrt_release_node api call
This commit is contained in:
parent
fe36139965
commit
fc578a67f1
|
@ -67,8 +67,9 @@ struct ks_dht_node_s {
|
||||||
ks_dht_nodeid_t nodeid;
|
ks_dht_nodeid_t nodeid;
|
||||||
ks_sockaddr_t addr;
|
ks_sockaddr_t addr;
|
||||||
enum ks_afflags_t family; /* AF_INET or AF_INET6 */
|
enum ks_afflags_t family; /* AF_INET or AF_INET6 */
|
||||||
enum ks_dht_nodetype_t type; /* local or remote */
|
enum ks_dht_nodetype_t type; /* local or remote */
|
||||||
ks_dhtrt_routetable_t* table;
|
ks_dhtrt_routetable_t* table;
|
||||||
|
ks_rwl_t *reflock;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ks_dhtrt_routetable_s {
|
struct ks_dhtrt_routetable_s {
|
||||||
|
@ -433,6 +434,7 @@ KS_DECLARE(ks_status_t) ks_dhtrt_expire_node(ks_dhtrt_routetable_t* table
|
||||||
|
|
||||||
KS_DECLARE(uint8_t) ks_dhtrt_findclosest_nodes(ks_dhtrt_routetable_t* table, ks_dhtrt_querynodes_t* query);
|
KS_DECLARE(uint8_t) ks_dhtrt_findclosest_nodes(ks_dhtrt_routetable_t* table, ks_dhtrt_querynodes_t* query);
|
||||||
KS_DECLARE(ks_dht_node_t*) ks_dhtrt_find_node(ks_dhtrt_routetable_t* table, ks_dht_nodeid_t id);
|
KS_DECLARE(ks_dht_node_t*) ks_dhtrt_find_node(ks_dhtrt_routetable_t* table, ks_dht_nodeid_t id);
|
||||||
|
KS_DECLARE(ks_status_t) ks_dhtrt_release_node(ks_dht_node_t* node);
|
||||||
|
|
||||||
KS_DECLARE(void) ks_dhtrt_process_table(ks_dhtrt_routetable_t* table);
|
KS_DECLARE(void) ks_dhtrt_process_table(ks_dhtrt_routetable_t* table);
|
||||||
|
|
||||||
|
|
|
@ -235,11 +235,12 @@ KS_DECLARE(ks_status_t) ks_dhtrt_create_node( ks_dhtrt_routetable_t *table,
|
||||||
memcpy(tnode->nodeid.id, nodeid.id, KS_DHT_NODEID_SIZE);
|
memcpy(tnode->nodeid.id, nodeid.id, KS_DHT_NODEID_SIZE);
|
||||||
tnode->type = type;
|
tnode->type = type;
|
||||||
|
|
||||||
if ((ks_addr_set(&tnode->addr, ip, port, tnode->family) != KS_STATUS_SUCCESS) ||
|
if (( ks_addr_set(&tnode->addr, ip, port, tnode->family) != KS_STATUS_SUCCESS) ||
|
||||||
(ks_dhtrt_insert_node(table, tnode) != KS_STATUS_SUCCESS)) {
|
( ks_dhtrt_insert_node(table, tnode) != KS_STATUS_SUCCESS) ||
|
||||||
ks_pool_free(table->pool, tnode);
|
( ks_rwl_create(&tnode->reflock, table->pool) != KS_STATUS_SUCCESS)) {
|
||||||
return KS_STATUS_FAIL;
|
ks_pool_free(table->pool, tnode);
|
||||||
}
|
return KS_STATUS_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
(*node) = tnode;
|
(*node) = tnode;
|
||||||
|
|
||||||
|
@ -258,6 +259,7 @@ KS_DECLARE(ks_status_t) ks_dhtrt_delete_node(ks_dhtrt_routetable_t *table, ks_dh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ks_rwl_destroy(&node->reflock);
|
||||||
ks_pool_free(table->pool, node);
|
ks_pool_free(table->pool, node);
|
||||||
return KS_STATUS_SUCCESS;
|
return KS_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -561,6 +563,14 @@ KS_DECLARE(uint8_t) ks_dhtrt_findclosest_nodes(ks_dhtrt_routetable_t *table, ks_
|
||||||
return query->count;
|
return query->count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KS_DECLARE(ks_status_t) ks_dhtrt_release_node(ks_dht_node_t* node)
|
||||||
|
{
|
||||||
|
return KS_STATUS_SUCCESS;
|
||||||
|
/* return ks_rwl_read_unlock(node->reflock);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
KS_DECLARE(void) ks_dhtrt_process_table(ks_dhtrt_routetable_t *table)
|
KS_DECLARE(void) ks_dhtrt_process_table(ks_dhtrt_routetable_t *table)
|
||||||
{
|
{
|
||||||
/* walk the table and update the status of all known knodes */
|
/* walk the table and update the status of all known knodes */
|
||||||
|
|
Loading…
Reference in New Issue