summaryrefslogtreecommitdiff
path: root/gio/gsocketinputstream.c
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2010-06-24 13:09:14 -0400
committerDan Winship <danw@gnome.org>2010-08-15 15:34:29 -0400
commit547311bfd8661e25e588e1f434f15c5f2f32c3a7 (patch)
tree34f1fb1cc859f7ed9ae8cae904cee1a96413764c /gio/gsocketinputstream.c
parent17fea2f749a407a15a82977b3488530cd5305266 (diff)
downloadglib-547311bfd8661e25e588e1f434f15c5f2f32c3a7.tar.gz
Always do async vs sync correctly in GSocketConnection streams
Previously if a GSocketConnection had a blocking GSocket, it would sometimes block during asynchonous I/O, and if it had a non-blocking socket, it would sometimes return G_IO_ERROR_WOULD_BLOCK from synchronous I/O. This fixes the connection to not depend on the socket state. https://bugzilla.gnome.org/show_bug.cgi?id=616458
Diffstat (limited to 'gio/gsocketinputstream.c')
-rw-r--r--gio/gsocketinputstream.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/gio/gsocketinputstream.c b/gio/gsocketinputstream.c
index 4b26ed4b9..07c474056 100644
--- a/gio/gsocketinputstream.c
+++ b/gio/gsocketinputstream.c
@@ -111,8 +111,9 @@ g_socket_input_stream_read (GInputStream *stream,
{
GSocketInputStream *input_stream = G_SOCKET_INPUT_STREAM (stream);
- return g_socket_receive (input_stream->priv->socket, buffer, count,
- cancellable, error);
+ return g_socket_receive_with_blocking (input_stream->priv->socket,
+ buffer, count, TRUE,
+ cancellable, error);
}
static gboolean
@@ -124,11 +125,12 @@ g_socket_input_stream_read_ready (GSocket *socket,
GError *error = NULL;
gssize result;
- result = g_socket_receive (stream->priv->socket,
- stream->priv->buffer,
- stream->priv->count,
- stream->priv->cancellable,
- &error);
+ result = g_socket_receive_with_blocking (stream->priv->socket,
+ stream->priv->buffer,
+ stream->priv->count,
+ FALSE,
+ stream->priv->cancellable,
+ &error);
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
return TRUE;