From 609ed80aaf8315a5ad0d658ece54e51e5da0984a Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 17 Apr 2017 14:36:46 -0500 Subject: [PATCH] Using the correct socket descriptor --- net/multistream.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/multistream.c b/net/multistream.c index 73375de..9bf23c8 100644 --- a/net/multistream.c +++ b/net/multistream.c @@ -19,7 +19,7 @@ int libp2p_net_multistream_close(void* stream_context) { struct SessionContext* secure_context = (struct SessionContext*)stream_context; struct Stream* stream = secure_context->insecure_stream; - close((intptr_t)stream->socket_descriptor); + close( *((int*)stream->socket_descriptor)); return 1; } @@ -69,9 +69,9 @@ int libp2p_net_multistream_read(void* stream_context, unsigned char** results, s // first read the varint while(1) { - unsigned char c; + unsigned char c = '\0'; bytes = socket_read(*((int*)stream->socket_descriptor), (char*)&c, 1, 0, timeout_secs); - if (bytes == 0) { // timeout + if (bytes <= 0) { // timeout return 0; } pos[0] = c;