summaryrefslogtreecommitdiff
blob: 5ae2d72cf3572a059f92919ae570c9d0ba07d5f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From b2315084cb21a1ef072a48b0238a2e614af78be3 Mon Sep 17 00:00:00 2001
From: Ted Gould <ted@gould.cx>
Date: Mon, 13 Dec 2010 18:33:15 +0000
Subject: Bug 635626 – GDBus message idle can execute while flushes are pending

https://bugzilla.gnome.org/show_bug.cgi?id=635626

Signed-off-by: David Zeuthen <davidz@redhat.com>
---
diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c
index dd9d58a..228c28c 100644
--- a/gio/gdbusprivate.c
+++ b/gio/gdbusprivate.c
@@ -431,6 +431,7 @@ struct GDBusWorker
   gint                                num_writes_pending;
   guint64                             write_num_messages_written;
   GList                              *write_pending_flushes;
+  gboolean                            flush_pending;
 };
 
 /* ---------------------------------------------------------------------------------------------------- */
@@ -1158,6 +1159,12 @@ ostream_flush_cb (GObject      *source_object,
   if (error != NULL)
     g_error_free (error);
 
+  /* Make sure we tell folks that we don't have additional
+     flushes pending */
+  g_mutex_lock (data->worker->write_lock);
+  data->worker->flush_pending = FALSE;
+  g_mutex_unlock (data->worker->write_lock);
+
   /* OK, cool, finally kick off the next write */
   maybe_write_next_message (data->worker);
 
@@ -1210,6 +1217,10 @@ message_written (GDBusWorker *worker,
           worker->write_pending_flushes = g_list_delete_link (worker->write_pending_flushes, l);
         }
     }
+  if (flushers != NULL)
+    {
+      worker->flush_pending = TRUE;
+    }
   g_mutex_unlock (worker->write_lock);
 
   if (flushers != NULL)
@@ -1344,7 +1355,7 @@ static gboolean
 write_message_in_idle_cb (gpointer user_data)
 {
   GDBusWorker *worker = user_data;
-  if (worker->num_writes_pending == 0)
+  if (worker->num_writes_pending == 0 && !worker->flush_pending)
     maybe_write_next_message (worker);
   return FALSE;
 }
@@ -1427,6 +1438,7 @@ _g_dbus_worker_new (GIOStream                              *stream,
   worker->stream = g_object_ref (stream);
   worker->capabilities = capabilities;
   worker->cancellable = g_cancellable_new ();
+  worker->flush_pending = FALSE;
 
   worker->frozen = initially_frozen;
   worker->received_messages_while_frozen = g_queue_new ();
--
cgit v0.8.3.1