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-01 19:07:54 +0000
commit618daf6ee5513659a50aaec8f0c7fb6c72675041 (patch)
treeb17426dd205d17d465709bea84b1a282767eb556
parent7d672c669990a61be4186c2652ebe168d089558b (diff)
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>
-rw-r--r--gio/gdbusprivate.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c
index 99ddfa752..c7b6db567 100644
--- a/gio/gdbusprivate.c
+++ b/gio/gdbusprivate.c
@@ -1498,16 +1498,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);
@@ -1527,8 +1525,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);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -1556,7 +1552,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);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -1636,7 +1634,9 @@ _g_dbus_worker_close (GDBusWorker *worker,
close_data->result = (result == NULL ? NULL : g_object_ref (result));
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