From 8b2a8ef3abd7423c298317ab468c1c6ce4baf8d3 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 6 Nov 2017 13:37:48 -0500 Subject: [PATCH] Minor changes for yamux --- core/ipfs_node.c | 3 +++ core/null.c | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/core/ipfs_node.c b/core/ipfs_node.c index 6a61dc7..05c43ee 100644 --- a/core/ipfs_node.c +++ b/core/ipfs_node.c @@ -2,6 +2,7 @@ #include #include "libp2p/conn/dialer.h" +#include "libp2p/identify/identify.h" #include "libp2p/net/multistream.h" #include "libp2p/utils/vector.h" #include "libp2p/secio/secio.h" @@ -45,6 +46,8 @@ struct Libp2pVector* ipfs_node_online_build_protocol_handlers(struct IpfsNode* n libp2p_utils_vector_add(retVal, libp2p_net_multistream_build_protocol_handler(retVal)); // yamux libp2p_utils_vector_add(retVal, yamux_build_protocol_handler()); + // identify + libp2p_utils_vector_add(retVal, libp2p_identify_build_protocol_handler(retVal)); } return retVal; } diff --git a/core/null.c b/core/null.c index f96d7d6..02a8289 100644 --- a/core/null.c +++ b/core/null.c @@ -35,7 +35,7 @@ static int null_shutting_down = 0; /** - * We've received a connection. Find out what they want. + * We've received a new connection. Find out what they want. * * @param ptr a pointer to a null_connection_params struct */ @@ -66,11 +66,13 @@ void ipfs_null_connection (void *ptr) { for(;;) { // Read from the network if (!session->default_stream->read(session, &results, DEFAULT_NETWORK_TIMEOUT)) { - // problem reading; - break; + // problem reading + break; + } + if (results != NULL) { + retVal = libp2p_protocol_marshal(results, session, connection_param->local_node->protocol_handlers); + libp2p_stream_message_free(results); } - retVal = libp2p_protocol_marshal(results, session, connection_param->local_node->protocol_handlers); - libp2p_stream_message_free(results); // exit the loop on error (or if they ask us to no longer loop by returning 0) if (retVal <= 0) break;