[libsoup] soup-connection: remove usage of GSocket directly



commit 7371b8299777e96183fc04cbdc376cc3c88c981f
Author: Marc-André Lureau <marcandre lureau gmail com>
Date:   Wed Feb 18 17:38:28 2015 +0100

    soup-connection: remove usage of GSocket directly
    
    Not strictly required since it's client-side code, but potentially
    SoupSocket could not have GSocket anymore, and it seems better to use
    more abstract pollable stream methods.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=744186

 libsoup/soup-connection.c     |    3 ++-
 libsoup/soup-socket-private.h |    1 +
 libsoup/soup-socket.c         |   11 +++++++++++
 3 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index 436b8cb..de897ac 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -637,7 +637,8 @@ soup_connection_get_state (SoupConnection *conn)
        priv = SOUP_CONNECTION_GET_PRIVATE (conn);
 
        if (priv->state == SOUP_CONNECTION_IDLE &&
-           g_socket_condition_check (soup_socket_get_gsocket (priv->socket), G_IO_IN))
+           (!soup_socket_is_connected (priv->socket) ||
+            soup_socket_is_readable (priv->socket)))
                soup_connection_set_state (conn, SOUP_CONNECTION_REMOTE_DISCONNECTED);
 
        if (priv->state == SOUP_CONNECTION_IDLE &&
diff --git a/libsoup/soup-socket-private.h b/libsoup/soup-socket-private.h
index a848a69..84fad04 100644
--- a/libsoup/soup-socket-private.h
+++ b/libsoup/soup-socket-private.h
@@ -39,6 +39,7 @@ gboolean   soup_socket_handshake_finish        (SoupSocket           *sock,
                                                GAsyncResult         *result,
                                                GError              **error);
 
+gboolean   soup_socket_is_readable             (SoupSocket           *sock);
 GSocket   *soup_socket_get_gsocket             (SoupSocket           *sock);
 GIOStream *soup_socket_get_connection          (SoupSocket           *sock);
 GIOStream *soup_socket_get_iostream            (SoupSocket           *sock);
diff --git a/libsoup/soup-socket.c b/libsoup/soup-socket.c
index 0881ef4..f067296 100644
--- a/libsoup/soup-socket.c
+++ b/libsoup/soup-socket.c
@@ -1128,6 +1128,17 @@ soup_socket_get_gsocket (SoupSocket *sock)
        return SOUP_SOCKET_GET_PRIVATE (sock)->gsock;
 }
 
+gboolean
+soup_socket_is_readable (SoupSocket *sock)
+{
+       SoupSocketPrivate *priv;
+
+       g_return_val_if_fail (SOUP_IS_SOCKET (sock), FALSE);
+       priv = SOUP_SOCKET_GET_PRIVATE (sock);
+
+       return g_pollable_input_stream_is_readable (G_POLLABLE_INPUT_STREAM (priv->istream));
+}
+
 GIOStream *
 soup_socket_get_connection (SoupSocket *sock)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]