Shut down handlers when app shuts down

This commit is contained in:
jmjatlanta 2017-08-09 12:21:03 -05:00
parent d226e480c9
commit dd69216c75

View file

@ -21,6 +21,15 @@ struct Libp2pVector* ipfs_node_online_build_protocol_handlers(struct IpfsNode* n
return retVal; return retVal;
} }
int ipfs_node_online_protocol_handlers_free(struct Libp2pVector* handlers) {
for(int i = 0; i < handlers->total; i++) {
struct Libp2pProtocolHandler* current = (struct Libp2pProtocolHandler*) libp2p_utils_vector_get(handlers, i);
current->Shutdown(current->context);
}
libp2p_utils_vector_free(handlers);
return 1;
}
/*** /***
* build an online IpfsNode * build an online IpfsNode
* @param repo_path where the IPFS repository directory is * @param repo_path where the IPFS repository directory is
@ -85,6 +94,8 @@ int ipfs_node_free(struct IpfsNode* node) {
libp2p_peerstore_free(node->peerstore); libp2p_peerstore_free(node->peerstore);
if (node->repo != NULL) if (node->repo != NULL)
ipfs_repo_fsrepo_free(node->repo); ipfs_repo_fsrepo_free(node->repo);
if (node->protocol_handlers != NULL)
ipfs_node_online_protocol_handlers_free(node->protocol_handlers);
if (node->mode == MODE_ONLINE) { if (node->mode == MODE_ONLINE) {
ipfs_routing_online_free(node->routing); ipfs_routing_online_free(node->routing);
} }