#include "glibintl.h"
static gboolean _g_dbus_worker_do_initial_read (gpointer data);
+static void schedule_pending_close (GDBusWorker *worker);
/* ---------------------------------------------------------------------------------------------------- */
/* gives up the reference acquired when calling g_input_stream_read_async() */
_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) */
/* if we want to close the connection, that takes precedence */
if (worker->pending_close_attempts != NULL)
{
- worker->close_expected = TRUE;
- worker->output_pending = PENDING_CLOSE;
+ GInputStream *input = g_io_stream_get_input_stream (worker->stream);
- g_io_stream_close_async (worker->stream, G_PRIORITY_DEFAULT,
- NULL, iostream_close_cb,
- _g_dbus_worker_ref (worker));
+ if (!g_input_stream_has_pending (input))
+ {
+ 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
{
}
}
+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