[libsoup] SoupConnection: belatedly fix up unix-only code
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] SoupConnection: belatedly fix up unix-only code
- Date: Thu, 22 Dec 2011 20:47:18 +0000 (UTC)
commit d4ec04f41d4de39a7b9091f0d0572ce11565a4ab
Author: Dan Winship <danw gnome org>
Date: Wed Dec 7 17:03:19 2011 -0500
SoupConnection: belatedly fix up unix-only code
The last-minute-check-if-the-socket-has-been-closed-by-the-server code
was written long ago to use soup_socket_get_fd() and g_poll(), and so
was unix-only, but now that SoupSocket is GSocket-based, we can use
g_socket_condition_check() instead.
libsoup/soup-connection.c | 15 ++++-----------
libsoup/soup-misc-private.h | 3 +++
libsoup/soup-socket.c | 8 ++++++++
3 files changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index 15260e4..af54e88 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -796,17 +796,10 @@ soup_connection_get_state (SoupConnection *conn)
SOUP_CONNECTION_DISCONNECTED);
priv = SOUP_CONNECTION_GET_PRIVATE (conn);
-#ifdef G_OS_UNIX
- if (priv->state == SOUP_CONNECTION_IDLE) {
- GPollFD pfd;
-
- pfd.fd = soup_socket_get_fd (priv->socket);
- pfd.events = G_IO_IN;
- pfd.revents = 0;
- if (g_poll (&pfd, 1, 0) == 1)
- soup_connection_set_state (conn, SOUP_CONNECTION_REMOTE_DISCONNECTED);
- }
-#endif
+ if (priv->state == SOUP_CONNECTION_IDLE &&
+ g_socket_condition_check (soup_socket_get_gsocket (priv->socket), G_IO_IN))
+ soup_connection_set_state (conn, SOUP_CONNECTION_REMOTE_DISCONNECTED);
+
if (priv->state == SOUP_CONNECTION_IDLE &&
priv->unused_timeout && priv->unused_timeout < time (NULL))
soup_connection_set_state (conn, SOUP_CONNECTION_REMOTE_DISCONNECTED);
diff --git a/libsoup/soup-misc-private.h b/libsoup/soup-misc-private.h
index 8407101..1d472f9 100644
--- a/libsoup/soup-misc-private.h
+++ b/libsoup/soup-misc-private.h
@@ -18,4 +18,7 @@ void soup_socket_handshake_async (SoupSocket *sock,
SoupSocketCallback callback,
gpointer user_data);
+GSocket *soup_socket_get_gsocket (SoupSocket *sock);
+
+
#endif /* SOUP_URI_PRIVATE_H */
diff --git a/libsoup/soup-socket.c b/libsoup/soup-socket.c
index 088ce0e..b4396c5 100644
--- a/libsoup/soup-socket.c
+++ b/libsoup/soup-socket.c
@@ -790,6 +790,14 @@ soup_socket_get_fd (SoupSocket *sock)
return g_socket_get_fd (SOUP_SOCKET_GET_PRIVATE (sock)->gsock);
}
+GSocket *
+soup_socket_get_gsocket (SoupSocket *sock)
+{
+ g_return_val_if_fail (SOUP_IS_SOCKET (sock), NULL);
+
+ return SOUP_SOCKET_GET_PRIVATE (sock)->gsock;
+}
+
static GSource *
soup_socket_create_watch (SoupSocketPrivate *priv, GIOCondition cond,
GPollableSourceFunc callback, gpointer user_data,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]