summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-10-21 14:46:47 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2011-11-21 16:06:09 +0000
commit210c0c0cd581cdf0af5a691c7e065001bb7be00b (patch)
tree6fc8e71e047ac462dabdd410b5e2a56d3618d37b
parent628eee1c7dd76d698a43645d510ac236bb34845d (diff)
downloadglib-210c0c0cd581cdf0af5a691c7e065001bb7be00b.tar.gz
schedule_write_in_worker_thread: require caller to lock; rename accordingly
When we use this function to schedule a flush, it'll be called with the lock held. Releasing and immediately re-taking the lock would be pointless. Bug: https://bugzilla.gnome.org/show_bug.cgi?id=662395 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk>
-rw-r--r--gio/gdbusprivate.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c
index 0b8506f90..28cfeac15 100644
--- a/gio/gdbusprivate.c
+++ b/gio/gdbusprivate.c
@@ -1528,16 +1528,14 @@ continue_writing_in_idle_cb (gpointer user_data)
*
* Can be called from any thread
*
- * write_lock is not held on entry
+ * write_lock is held on entry
* output_pending may be anything
*/
static void
-schedule_write_in_worker_thread (GDBusWorker *worker,
- MessageToWriteData *write_data,
- CloseData *close_data)
+schedule_writing_unlocked (GDBusWorker *worker,
+ MessageToWriteData *write_data,
+ CloseData *close_data)
{
- g_mutex_lock (worker->write_lock);
-
if (write_data != NULL)
g_queue_push_tail (worker->write_queue, write_data);
@@ -1557,8 +1555,6 @@ schedule_write_in_worker_thread (GDBusWorker *worker,
g_source_attach (idle_source, worker->shared_thread_data->context);
g_source_unref (idle_source);
}
-
- g_mutex_unlock (worker->write_lock);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -1586,7 +1582,9 @@ _g_dbus_worker_send_message (GDBusWorker *worker,
data->blob = blob; /* steal! */
data->blob_size = blob_len;
- schedule_write_in_worker_thread (worker, data, NULL);
+ g_mutex_lock (worker->write_lock);
+ schedule_writing_unlocked (worker, data, NULL);
+ g_mutex_unlock (worker->write_lock);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -1669,7 +1667,9 @@ _g_dbus_worker_close (GDBusWorker *worker,
* It'll be set before the actual close happens.
*/
g_cancellable_cancel (worker->cancellable);
- schedule_write_in_worker_thread (worker, NULL, close_data);
+ g_mutex_lock (worker->write_lock);
+ schedule_writing_unlocked (worker, NULL, close_data);
+ g_mutex_unlock (worker->write_lock);
}
/* This can be called from any thread - frees worker. Note that