mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 14:36:16 +01:00
gsocket: use cancellable child source
Now that GCancellable's GSource is based on _set_ready_time() instead of an fd, we should use it as a child source, instead of forcing the creation of the fd and adding it as a poll. https://bugzilla.gnome.org/show_bug.cgi?id=724707
This commit is contained in:
parent
d8263dd793
commit
ff96f88e17
@ -3207,8 +3207,6 @@ typedef struct {
|
|||||||
GPollFD pollfd;
|
GPollFD pollfd;
|
||||||
GSocket *socket;
|
GSocket *socket;
|
||||||
GIOCondition condition;
|
GIOCondition condition;
|
||||||
GCancellable *cancellable;
|
|
||||||
GPollFD cancel_pollfd;
|
|
||||||
gint64 timeout_time;
|
gint64 timeout_time;
|
||||||
} GSocketSource;
|
} GSocketSource;
|
||||||
|
|
||||||
@ -3218,9 +3216,6 @@ socket_source_prepare (GSource *source,
|
|||||||
{
|
{
|
||||||
GSocketSource *socket_source = (GSocketSource *)source;
|
GSocketSource *socket_source = (GSocketSource *)source;
|
||||||
|
|
||||||
if (g_cancellable_is_cancelled (socket_source->cancellable))
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
if (socket_source->timeout_time)
|
if (socket_source->timeout_time)
|
||||||
{
|
{
|
||||||
gint64 now;
|
gint64 now;
|
||||||
@ -3299,12 +3294,6 @@ socket_source_finalize (GSource *source)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_object_unref (socket);
|
g_object_unref (socket);
|
||||||
|
|
||||||
if (socket_source->cancellable)
|
|
||||||
{
|
|
||||||
g_cancellable_release_fd (socket_source->cancellable);
|
|
||||||
g_object_unref (socket_source->cancellable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -3371,11 +3360,14 @@ socket_source_new (GSocket *socket,
|
|||||||
socket_source->socket = g_object_ref (socket);
|
socket_source->socket = g_object_ref (socket);
|
||||||
socket_source->condition = condition;
|
socket_source->condition = condition;
|
||||||
|
|
||||||
if (g_cancellable_make_pollfd (cancellable,
|
if (cancellable)
|
||||||
&socket_source->cancel_pollfd))
|
|
||||||
{
|
{
|
||||||
socket_source->cancellable = g_object_ref (cancellable);
|
GSource *cancellable_source;
|
||||||
g_source_add_poll (source, &socket_source->cancel_pollfd);
|
|
||||||
|
cancellable_source = g_cancellable_source_new (cancellable);
|
||||||
|
g_source_add_child_source (source, cancellable_source);
|
||||||
|
g_source_set_dummy_callback (cancellable_source);
|
||||||
|
g_source_unref (cancellable_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
|
Loading…
Reference in New Issue
Block a user