Still testing bitswap
This commit is contained in:
parent
73d7d5daed
commit
b3bb857f3a
8 changed files with 62 additions and 41 deletions
|
@ -53,6 +53,9 @@ struct Exchange* ipfs_bitswap_new(struct IpfsNode* ipfs_node) {
|
|||
int ipfs_bitswap_free(struct Exchange* exchange) {
|
||||
if (exchange != NULL) {
|
||||
if (exchange->exchangeContext != NULL) {
|
||||
struct BitswapContext* bitswapContext = (struct BitswapContext*) exchange->exchangeContext;
|
||||
if (bitswapContext != NULL)
|
||||
ipfs_bitswap_engine_stop(bitswapContext);
|
||||
free(exchange->exchangeContext);
|
||||
}
|
||||
free(exchange);
|
||||
|
|
|
@ -101,5 +101,7 @@ int ipfs_bitswap_engine_stop(const struct BitswapContext* context) {
|
|||
int error1 = pthread_join(context->bitswap_engine->wantlist_processor_thread, NULL);
|
||||
int error2 = pthread_join(context->bitswap_engine->peer_request_processor_thread, NULL);
|
||||
|
||||
ipfs_bitswap_engine_free(context->bitswap_engine);
|
||||
|
||||
return !error1 && !error2;
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ struct WantListQueueEntry* ipfs_bitswap_wantlist_queue_find(struct WantListQueue
|
|||
struct WantListQueueEntry* ipfs_bitswap_wantlist_queue_pop(struct WantListQueue* wantlist) {
|
||||
struct WantListQueueEntry* entry = NULL;
|
||||
|
||||
if (wantlist->queue->total == 0)
|
||||
if (wantlist == NULL || wantlist->queue == NULL || wantlist->queue->total == 0)
|
||||
return entry;
|
||||
|
||||
//TODO: This should be a linked list, not an array
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue