mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 07:26:15 +01:00
gdbus: delay closing stream after read finish
Closing the stream on the writing side my race with a pending read. This patch ensures that closing is delayed after reading is finished. https://bugzilla.gnome.org/show_bug.cgi?id=743990
This commit is contained in:
parent
c7f0ea4354
commit
512e9b3b34
@ -52,6 +52,7 @@
|
|||||||
#include "glibintl.h"
|
#include "glibintl.h"
|
||||||
|
|
||||||
static gboolean _g_dbus_worker_do_initial_read (gpointer data);
|
static gboolean _g_dbus_worker_do_initial_read (gpointer data);
|
||||||
|
static void schedule_pending_close (GDBusWorker *worker);
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
@ -817,6 +818,9 @@ _g_dbus_worker_do_read_cb (GInputStream *input_stream,
|
|||||||
|
|
||||||
/* gives up the reference acquired when calling g_input_stream_read_async() */
|
/* gives up the reference acquired when calling g_input_stream_read_async() */
|
||||||
_g_dbus_worker_unref (worker);
|
_g_dbus_worker_unref (worker);
|
||||||
|
|
||||||
|
/* check if there is any pending close */
|
||||||
|
schedule_pending_close (worker);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* called in private thread shared by all GDBusConnection instances (with read-lock held) */
|
/* called in private thread shared by all GDBusConnection instances (with read-lock held) */
|
||||||
@ -1445,12 +1449,17 @@ continue_writing (GDBusWorker *worker)
|
|||||||
/* if we want to close the connection, that takes precedence */
|
/* if we want to close the connection, that takes precedence */
|
||||||
if (worker->pending_close_attempts != NULL)
|
if (worker->pending_close_attempts != NULL)
|
||||||
{
|
{
|
||||||
worker->close_expected = TRUE;
|
GInputStream *input = g_io_stream_get_input_stream (worker->stream);
|
||||||
worker->output_pending = PENDING_CLOSE;
|
|
||||||
|
|
||||||
g_io_stream_close_async (worker->stream, G_PRIORITY_DEFAULT,
|
if (!g_input_stream_has_pending (input))
|
||||||
NULL, iostream_close_cb,
|
{
|
||||||
_g_dbus_worker_ref (worker));
|
worker->close_expected = TRUE;
|
||||||
|
worker->output_pending = PENDING_CLOSE;
|
||||||
|
|
||||||
|
g_io_stream_close_async (worker->stream, G_PRIORITY_DEFAULT,
|
||||||
|
NULL, iostream_close_cb,
|
||||||
|
_g_dbus_worker_ref (worker));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1603,6 +1612,15 @@ schedule_writing_unlocked (GDBusWorker *worker,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
schedule_pending_close (GDBusWorker *worker)
|
||||||
|
{
|
||||||
|
if (!worker->pending_close_attempts)
|
||||||
|
return;
|
||||||
|
|
||||||
|
schedule_writing_unlocked (worker, NULL, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* can be called from any thread - steals blob
|
/* can be called from any thread - steals blob
|
||||||
|
Loading…
Reference in New Issue
Block a user