mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-10 03:04:05 +02:00
GDBusWorker: annotate more functions with lock/pending state
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=651268 Bug-NB: NB#271520 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
committed by
David Zeuthen
parent
8097e2de85
commit
c180ea13ae
@@ -378,10 +378,13 @@ struct GDBusWorker
|
|||||||
gboolean output_pending;
|
gboolean output_pending;
|
||||||
/* used for writing */
|
/* used for writing */
|
||||||
GMutex *write_lock;
|
GMutex *write_lock;
|
||||||
|
/* queue of MessageToWriteData, protected by write_lock */
|
||||||
GQueue *write_queue;
|
GQueue *write_queue;
|
||||||
|
/* protected by write_lock */
|
||||||
guint64 write_num_messages_written;
|
guint64 write_num_messages_written;
|
||||||
|
/* list of FlushData, protected by write_lock */
|
||||||
GList *write_pending_flushes;
|
GList *write_pending_flushes;
|
||||||
/* list of CloseData */
|
/* list of CloseData, protected by write_lock */
|
||||||
GList *pending_close_attempts;
|
GList *pending_close_attempts;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -860,7 +863,11 @@ message_to_write_data_free (MessageToWriteData *data)
|
|||||||
|
|
||||||
static void write_message_continue_writing (MessageToWriteData *data);
|
static void write_message_continue_writing (MessageToWriteData *data);
|
||||||
|
|
||||||
/* called in private thread shared by all GDBusConnection instances (without write-lock held) */
|
/* called in private thread shared by all GDBusConnection instances
|
||||||
|
*
|
||||||
|
* write-lock is not held on entry
|
||||||
|
* output_pending is true on entry
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
write_message_async_cb (GObject *source_object,
|
write_message_async_cb (GObject *source_object,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
@@ -906,7 +913,11 @@ write_message_async_cb (GObject *source_object,
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* called in private thread shared by all GDBusConnection instances (without write-lock held) */
|
/* called in private thread shared by all GDBusConnection instances
|
||||||
|
*
|
||||||
|
* write-lock is not held on entry
|
||||||
|
* output_pending is true on entry
|
||||||
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
on_socket_ready (GSocket *socket,
|
on_socket_ready (GSocket *socket,
|
||||||
GIOCondition condition,
|
GIOCondition condition,
|
||||||
@@ -917,7 +928,11 @@ on_socket_ready (GSocket *socket,
|
|||||||
return FALSE; /* remove source */
|
return FALSE; /* remove source */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* called in private thread shared by all GDBusConnection instances (without write-lock held) */
|
/* called in private thread shared by all GDBusConnection instances
|
||||||
|
*
|
||||||
|
* write-lock is not held on entry
|
||||||
|
* output_pending is true on entry
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
write_message_continue_writing (MessageToWriteData *data)
|
write_message_continue_writing (MessageToWriteData *data)
|
||||||
{
|
{
|
||||||
@@ -1050,7 +1065,11 @@ write_message_continue_writing (MessageToWriteData *data)
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* called in private thread shared by all GDBusConnection instances (without write-lock held) */
|
/* called in private thread shared by all GDBusConnection instances
|
||||||
|
*
|
||||||
|
* write-lock is not held on entry
|
||||||
|
* output_pending is true on entry
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
write_message_async (GDBusWorker *worker,
|
write_message_async (GDBusWorker *worker,
|
||||||
MessageToWriteData *data,
|
MessageToWriteData *data,
|
||||||
@@ -1104,7 +1123,11 @@ flush_data_list_complete (const GList *flushers,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* called in private thread shared by all GDBusConnection instances (without write-lock held) */
|
/* called in private thread shared by all GDBusConnection instances
|
||||||
|
*
|
||||||
|
* write-lock is not held on entry
|
||||||
|
* output_pending is true on entry
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
ostream_flush_cb (GObject *source_object,
|
ostream_flush_cb (GObject *source_object,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
@@ -1152,7 +1175,11 @@ ostream_flush_cb (GObject *source_object,
|
|||||||
g_free (data);
|
g_free (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* called in private thread shared by all GDBusConnection instances (without write-lock held) */
|
/* called in private thread shared by all GDBusConnection instances
|
||||||
|
*
|
||||||
|
* write-lock is not held on entry
|
||||||
|
* output_pending is false on entry
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
message_written (GDBusWorker *worker,
|
message_written (GDBusWorker *worker,
|
||||||
MessageToWriteData *message_data)
|
MessageToWriteData *message_data)
|
||||||
@@ -1224,7 +1251,11 @@ message_written (GDBusWorker *worker,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* called in private thread shared by all GDBusConnection instances (without write-lock held) */
|
/* called in private thread shared by all GDBusConnection instances
|
||||||
|
*
|
||||||
|
* write-lock is not held on entry
|
||||||
|
* output_pending is true on entry
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
write_message_cb (GObject *source_object,
|
write_message_cb (GObject *source_object,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
@@ -1325,7 +1356,11 @@ iostream_close_cb (GObject *source_object,
|
|||||||
_g_dbus_worker_unref (worker);
|
_g_dbus_worker_unref (worker);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* called in private thread shared by all GDBusConnection instances (without write-lock held) */
|
/* called in private thread shared by all GDBusConnection instances
|
||||||
|
*
|
||||||
|
* write-lock is not held on entry
|
||||||
|
* output_pending must be false on entry
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
maybe_write_next_message (GDBusWorker *worker)
|
maybe_write_next_message (GDBusWorker *worker)
|
||||||
{
|
{
|
||||||
@@ -1420,7 +1455,11 @@ maybe_write_next_message (GDBusWorker *worker)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* called in private thread shared by all GDBusConnection instances (without write-lock held) */
|
/* called in private thread shared by all GDBusConnection instances
|
||||||
|
*
|
||||||
|
* write-lock is not held on entry
|
||||||
|
* output_pending may be true or false
|
||||||
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
write_message_in_idle_cb (gpointer user_data)
|
write_message_in_idle_cb (gpointer user_data)
|
||||||
{
|
{
|
||||||
@@ -1476,7 +1515,11 @@ schedule_write_in_worker_thread (GDBusWorker *worker,
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* can be called from any thread - steals blob */
|
/* can be called from any thread - steals blob
|
||||||
|
*
|
||||||
|
* write_lock is not held on entry
|
||||||
|
* output_pending may be true or false
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
_g_dbus_worker_send_message (GDBusWorker *worker,
|
_g_dbus_worker_send_message (GDBusWorker *worker,
|
||||||
GDBusMessage *message,
|
GDBusMessage *message,
|
||||||
@@ -1581,6 +1624,9 @@ _g_dbus_worker_close (GDBusWorker *worker,
|
|||||||
/* This can be called from any thread - frees worker. Note that
|
/* This can be called from any thread - frees worker. Note that
|
||||||
* callbacks might still happen if called from another thread than the
|
* callbacks might still happen if called from another thread than the
|
||||||
* worker - use your own synchronization primitive in the callbacks.
|
* worker - use your own synchronization primitive in the callbacks.
|
||||||
|
*
|
||||||
|
* write_lock is not held on entry
|
||||||
|
* output_pending may be true or false
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_g_dbus_worker_stop (GDBusWorker *worker)
|
_g_dbus_worker_stop (GDBusWorker *worker)
|
||||||
@@ -1604,6 +1650,9 @@ _g_dbus_worker_stop (GDBusWorker *worker)
|
|||||||
/* can be called from any thread (except the worker thread) - blocks
|
/* can be called from any thread (except the worker thread) - blocks
|
||||||
* calling thread until all queued outgoing messages are written and
|
* calling thread until all queued outgoing messages are written and
|
||||||
* the transport has been flushed
|
* the transport has been flushed
|
||||||
|
*
|
||||||
|
* write_lock is not held on entry
|
||||||
|
* output_pending may be true or false
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
_g_dbus_worker_flush_sync (GDBusWorker *worker,
|
_g_dbus_worker_flush_sync (GDBusWorker *worker,
|
||||||
|
Reference in New Issue
Block a user