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.
SOUP_CONNECTION_DISCONNECTED);
priv = SOUP_CONNECTION_GET_PRIVATE (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);
if (priv->state == SOUP_CONNECTION_IDLE &&
priv->unused_timeout && priv->unused_timeout < time (NULL))
soup_connection_set_state (conn, SOUP_CONNECTION_REMOTE_DISCONNECTED);
SoupSocketCallback callback,
gpointer user_data);
SoupSocketCallback callback,
gpointer user_data);
+GSocket *soup_socket_get_gsocket (SoupSocket *sock);
+
+
#endif /* SOUP_URI_PRIVATE_H */
#endif /* SOUP_URI_PRIVATE_H */
return g_socket_get_fd (SOUP_SOCKET_GET_PRIVATE (sock)->gsock);
}
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,
static GSource *
soup_socket_create_watch (SoupSocketPrivate *priv, GIOCondition cond,
GPollableSourceFunc callback, gpointer user_data,