From 89f3f162a54a04654bdb87ffb522efffae46ec80 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Thu, 24 Mar 2016 18:27:54 -0400 Subject: [PATCH] rfbsrc: Check for connection being closed Although it's not very well documented, g_input_stream_read_all() will set the number of bytes read to 0 if the connection is closed rather then returning an error. --- gst/librfb/rfbdecoder.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gst/librfb/rfbdecoder.c b/gst/librfb/rfbdecoder.c index 9142f1dcbe..e6eb70135a 100644 --- a/gst/librfb/rfbdecoder.c +++ b/gst/librfb/rfbdecoder.c @@ -188,6 +188,7 @@ rfb_decoder_read (RfbDecoder * decoder, guint32 len) { GInputStream *in; GError *err = NULL; + gsize count = 0; if (!decoder->connection) return FALSE; @@ -204,10 +205,16 @@ rfb_decoder_read (RfbDecoder * decoder, guint32 len) decoder->data_len = len; } - if (!g_input_stream_read_all (in, decoder->data, len, NULL, + if (!g_input_stream_read_all (in, decoder->data, len, &count, decoder->cancellable, &err)) goto recv_error; + if (count == 0) { + g_set_error_literal (&err, G_IO_ERROR, G_IO_ERROR_BROKEN_PIPE, + "Connection was closed."); + goto recv_error; + } + return decoder->data; recv_error: