summaryrefslogtreecommitdiff
path: root/recipes/dbus/dbus-glib-0.82/fix-async-dbus.patch
blob: 0cea12431f4fe23730580e721ee5ca4934ccdf29 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
diff -ur dbus-glib-0.78/dbus/dbus-gproxy.c patched/dbus-glib-0.78/dbus/dbus-gproxy.c
--- dbus-glib-0.78/dbus/dbus-gproxy.c	2008-11-17 19:45:50.000000000 +0100
+++ patched/dbus-glib-0.78/dbus/dbus-gproxy.c	2009-01-30 18:12:51.000000000 +0100
@@ -2175,6 +2175,41 @@
   return NULL;
 }
 
+struct dbus_g_proxy_begin_call_internal_helper_args
+{
+  DBusGProxy          *proxy;
+  DBusGProxyCallNotify notify;
+  guint                call_id;
+  gpointer             user_data;
+  GDestroyNotify       destroy;
+};
+
+static void
+dbus_g_proxy_begin_call_internal_helper (DBusPendingCall *pending, void *user_data)
+{
+  struct dbus_g_proxy_begin_call_internal_helper_args *t1 = user_data;
+  DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(t1->proxy);
+  GPendingNotifyClosure *closure;
+
+
+  t1->call_id = ++priv->call_id_counter;
+
+  if (t1->notify != NULL)
+    {
+      closure = g_new (GPendingNotifyClosure, 1);
+      closure->proxy = t1->proxy; /* No need to ref as the lifecycle is tied to proxy */
+      closure->call_id = t1->call_id;
+      closure->func = t1->notify;
+      closure->data = t1->user_data;
+      closure->free_data_func = t1->destroy;
+      dbus_pending_call_set_notify (pending, d_pending_call_notify,
+				    closure,
+				    d_pending_call_free);
+    }
+
+  g_hash_table_insert (priv->pending_calls, GUINT_TO_POINTER (t1->call_id), pending);
+}
+
 static guint
 dbus_g_proxy_begin_call_internal (DBusGProxy          *proxy,
 				  const char          *method,
@@ -2182,52 +2217,42 @@
 				  gpointer             user_data,
 				  GDestroyNotify       destroy,
 				  GValueArray         *args,
-				  int timeout)
+				  int                  timeout)
 {
+  struct dbus_g_proxy_begin_call_internal_helper_args t1;
+
   DBusMessage *message;
   DBusPendingCall *pending;
-  GPendingNotifyClosure *closure;
-  guint call_id;
   DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
 
+  t1.proxy = proxy;
+  t1.notify = notify;
+  t1.user_data = user_data;
+  t1.destroy = destroy;
+
   pending = NULL;
 
   message = dbus_g_proxy_marshal_args_to_message (proxy, method, args);
   if (!message)
     goto oom;
 
-  if (!dbus_connection_send_with_reply (priv->manager->connection,
-                                        message,
-                                        &pending,
-                                        timeout))
+  if (!dbus_connection_send_with_reply_setup (priv->manager->connection,
+                                              message,
+                                              &pending,
+                                              dbus_g_proxy_begin_call_internal_helper,
+                                              &t1,
+                                              timeout))
     goto oom;
   dbus_message_unref (message);
-  
+
   /* If we got a NULL pending, that means the connection was disconnected,
-   * and we need to abort this call.  
+   * and we need to abort this call.
    * https://bugs.freedesktop.org/show_bug.cgi?id=12675
    */
   if (pending == NULL)
     return 0;
 
-  call_id = ++priv->call_id_counter;
-
-  if (notify != NULL)
-    {
-      closure = g_new (GPendingNotifyClosure, 1);
-      closure->proxy = proxy; /* No need to ref as the lifecycle is tied to proxy */
-      closure->call_id = call_id;
-      closure->func = notify;
-      closure->data = user_data;
-      closure->free_data_func = destroy;
-      dbus_pending_call_set_notify (pending, d_pending_call_notify,
-				    closure,
-				    d_pending_call_free);
-    }
-
-  g_hash_table_insert (priv->pending_calls, GUINT_TO_POINTER (call_id), pending);
-
-  return call_id;
+  return t1.call_id;
  oom:
   g_error ("Out of memory");
   return 0;