g_socket_client_connect_async: fix when g_socket_connect succeeds immediately

https://bugzilla.gnome.org/show_bug.cgi?id=629251
This commit is contained in:
Dan Winship 2010-09-10 09:12:17 -04:00
parent 59383c8bea
commit bc29aa9b09

View File

@ -1068,6 +1068,22 @@ g_socket_client_proxy_connect (GSocketClientAsyncConnectData *data)
}
}
static void
g_socket_client_socket_connected (GSocketClientAsyncConnectData *data)
{
g_socket_set_blocking (data->current_socket, TRUE);
data->connection =
g_socket_connection_factory_create_connection (data->current_socket);
g_object_unref (data->current_socket);
data->current_socket = NULL;
if (data->proxy_addr)
g_socket_client_proxy_connect (data);
else
g_socket_client_async_connect_complete (data);
}
static gboolean
g_socket_client_socket_callback (GSocket *socket,
GIOCondition condition,
@ -1103,18 +1119,7 @@ g_socket_client_socket_callback (GSocket *socket,
}
}
g_socket_set_blocking (data->current_socket, TRUE);
data->connection =
g_socket_connection_factory_create_connection (data->current_socket);
g_object_unref (data->current_socket);
data->current_socket = NULL;
if (data->proxy_addr)
g_socket_client_proxy_connect (data);
else
g_socket_client_async_connect_complete (data);
g_socket_client_socket_connected (data);
return FALSE;
}
@ -1164,7 +1169,7 @@ g_socket_client_enumerator_callback (GObject *object,
if (g_socket_connect (socket, address, data->cancellable, &tmp_error))
{
data->current_socket = socket;
g_socket_client_async_connect_complete (data);
g_socket_client_socket_connected (data);
g_object_unref (address);
return;