Verify good connection before using it.

This commit is contained in:
jmjatlanta 2017-08-03 13:36:53 -05:00
parent d1d4d19fa8
commit ef53c886a0

View file

@ -82,6 +82,9 @@ void* ipfs_bitswap_engine_peer_request_processor_start(void* ctx) {
break;
}
if (current_peer_entry->connection_type == CONNECTION_TYPE_CONNECTED) {
if (current_peer_entry->sessionContext == NULL || current_peer_entry->sessionContext->default_stream == NULL) {
current_peer_entry->connection_type = CONNECTION_TYPE_NOT_CONNECTED;
} else {
libp2p_logger_debug("bitswap_engine", "We're connected to this peer. Lets see if there is a message waiting for us.\n");
int retVal = current_peer_entry->sessionContext->default_stream->peek(current_peer_entry->sessionContext);
if (retVal < 0) {
@ -102,6 +105,7 @@ void* ipfs_bitswap_engine_peer_request_processor_start(void* ctx) {
}
}
}
}
} else {
if (current_peer_entry->is_local) {
//libp2p_logger_debug("bitswap_engine", "Local peer %s. Skipping.\n", current_peer_entry->id);