Commit 0c65f7e4 authored by Olivier Crête's avatar Olivier Crête

GSocket: ignore timed out state when not relevant

Do this by separating the timeout check from the other socket checks.

https://bugzilla.gnome.org/show_bug.cgi?id=726375
parent 1e8c4d2a
......@@ -328,6 +328,13 @@ check_socket (GSocket *socket,
return FALSE;
}
return TRUE;
}
static gboolean
check_timeout (GSocket *socket,
GError **error)
{
if (socket->priv->timed_out)
{
socket->priv->timed_out = FALSE;
......@@ -2232,6 +2239,9 @@ g_socket_accept (GSocket *socket,
if (!check_socket (socket, error))
return NULL;
if (!check_timeout (socket, error))
return NULL;
while (TRUE)
{
if (socket->priv->blocking &&
......@@ -2428,6 +2438,9 @@ g_socket_check_connect_result (GSocket *socket,
if (!check_socket (socket, error))
return FALSE;
if (!check_timeout (socket, error))
return FALSE;
if (!g_socket_get_option (socket, SOL_SOCKET, SO_ERROR, &value, error))
{
g_prefix_error (error, _("Unable to get pending error: "));
......@@ -2595,6 +2608,9 @@ g_socket_receive_with_blocking (GSocket *socket,
if (!check_socket (socket, error))
return -1;
if (!check_timeout (socket, error))
return -1;
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return -1;
......@@ -2770,6 +2786,9 @@ g_socket_send_with_blocking (GSocket *socket,
if (!check_socket (socket, error))
return -1;
if (!check_timeout (socket, error))
return -1;
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return -1;
......@@ -3751,6 +3770,9 @@ g_socket_send_message (GSocket *socket,
if (!check_socket (socket, error))
return -1;
if (!check_timeout (socket, error))
return -1;
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return -1;
......@@ -4127,6 +4149,9 @@ g_socket_receive_message (GSocket *socket,
if (!check_socket (socket, error))
return -1;
if (!check_timeout (socket, error))
return -1;
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment