summaryrefslogtreecommitdiff
path: root/sysutils/dbus/patches/patch-ad
blob: 3e5ca5c5d12d36a8b7b3a7f636244a95e24931a5 (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
$NetBSD: patch-ad,v 1.3 2008/06/19 01:56:44 bjs Exp $

git ref: 	cdca6dbce88fd1e1195e2a81eb6619c782df2fac
 	 	Prevent a crash in some applications due to timers 
 	 	leaking after the DVusPendingCall object was freed.

git ref: 	d7bb3cf8dfc162007caf5e28d9c304381de7b8c3
 	 	Fix inverted return value from dbus_connection_read_write()

also:		fix f.d.o. bug 15635

--- dbus/dbus-connection.c.orig	2008-04-04 11:24:08.000000000 -0400
+++ dbus/dbus-connection.c
@@ -965,6 +965,13 @@ _dbus_connection_detach_pending_call_and
   _dbus_pending_call_ref_unlocked (pending);
   _dbus_hash_table_remove_int (connection->pending_replies,
                                _dbus_pending_call_get_reply_serial_unlocked (pending));
+
+  if (_dbus_pending_call_is_timeout_added_unlocked (pending))
+      _dbus_connection_remove_timeout_unlocked (connection,
+              _dbus_pending_call_get_timeout_unlocked (pending));
+
+  _dbus_pending_call_set_timeout_added_unlocked (pending, FALSE);
+
   _dbus_pending_call_unref_and_unlock (pending);
 }
 
@@ -1671,21 +1678,26 @@ connection_forget_shared_unlocked (DBusC
   if (!connection->shareable)
     return;
   
+  _DBUS_LOCK (shared_connections);
+      
   if (connection->server_guid != NULL)
     {
       _dbus_verbose ("dropping connection to %s out of the shared table\n",
                      connection->server_guid);
       
-      _DBUS_LOCK (shared_connections);
-      
       if (!_dbus_hash_table_remove_string (shared_connections,
                                            connection->server_guid))
         _dbus_assert_not_reached ("connection was not in the shared table");
       
       dbus_free (connection->server_guid);
       connection->server_guid = NULL;
-      _DBUS_UNLOCK (shared_connections);
     }
+  else
+    {
+      _dbus_list_remove (&shared_connections_no_guid, connection);
+    }
+
+  _DBUS_UNLOCK (shared_connections);
   
   /* remove our reference held on all shareable connections */
   _dbus_connection_unref_unlocked (connection);
@@ -3405,6 +3417,12 @@ _dbus_connection_read_write_dispatch (DB
 {
   DBusDispatchStatus dstatus;
   dbus_bool_t no_progress_possible;
+
+  /* Need to grab a ref here in case we're a private connection and
+   * the user drops the last ref in a handler we call; see bug 
+   * https://bugs.freedesktop.org/show_bug.cgi?id=15635
+   */
+  dbus_connection_ref (connection);
   
   dstatus = dbus_connection_get_dispatch_status (connection);
 
@@ -3444,7 +3462,11 @@ _dbus_connection_read_write_dispatch (DB
       connection->disconnect_message_link == NULL;
   else
     no_progress_possible = _dbus_connection_get_is_connected_unlocked (connection);
+
   CONNECTION_UNLOCK (connection);
+
+  dbus_connection_unref (connection);
+
   return !no_progress_possible; /* TRUE if we can make more progress */
 }