summaryrefslogtreecommitdiff
path: root/recipes/dbus/dbus-1.3.0/will-5.patch
blob: ed100005cfa38bb32ee6d1384d8c91225de20973 (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
116
From a40a026527e718547f32e134e7c27a561b1eba47 Mon Sep 17 00:00:00 2001
From: Will Thompson <will.thompson@collabora.co.uk>
Date: Wed, 29 Jul 2009 20:03:40 +0100
Subject: [PATCH 5/6] Extract rule_list_remove_by_connection

---
 bus/signals.c |   82 +++++++++++++++++++++++++++++++-------------------------
 1 files changed, 45 insertions(+), 37 deletions(-)

diff --git a/bus/signals.c b/bus/signals.c
index 3cf846e..c6f122b 100644
--- a/bus/signals.c
+++ b/bus/signals.c
@@ -1285,11 +1285,54 @@ bus_matchmaker_remove_rule_by_value (BusMatchmaker   *matchmaker,
   return TRUE;
 }
 
+static void
+rule_list_remove_by_connection (DBusList       **rules,
+                                DBusConnection  *disconnected)
+{
+  DBusList *link;
+
+  link = _dbus_list_get_first_link (rules);
+  while (link != NULL)
+    {
+      BusMatchRule *rule;
+      DBusList *next;
+
+      rule = link->data;
+      next = _dbus_list_get_next_link (rules, link);
+
+      if (rule->matches_go_to == disconnected)
+        {
+          bus_matchmaker_remove_rule_link (rules, link);
+        }
+      else if (((rule->flags & BUS_MATCH_SENDER) && *rule->sender == ':') ||
+               ((rule->flags & BUS_MATCH_DESTINATION) && *rule->destination == ':'))
+        {
+          /* The rule matches to/from a base service, see if it's the
+           * one being disconnected, since we know this service name
+           * will never be recycled.
+           */
+          const char *name;
+
+          name = bus_connection_get_name (disconnected);
+          _dbus_assert (name != NULL); /* because we're an active connection */
+
+          if (((rule->flags & BUS_MATCH_SENDER) &&
+               strcmp (rule->sender, name) == 0) ||
+              ((rule->flags & BUS_MATCH_DESTINATION) &&
+               strcmp (rule->destination, name) == 0))
+            {
+              bus_matchmaker_remove_rule_link (rules, link);
+            }
+        }
+
+      link = next;
+    }
+}
+
 void
 bus_matchmaker_disconnected (BusMatchmaker   *matchmaker,
                              DBusConnection  *disconnected)
 {
-  DBusList *link;
   int i;
 
   /* FIXME
@@ -1307,42 +1350,7 @@ bus_matchmaker_disconnected (BusMatchmaker   *matchmaker,
     {
       DBusList **rules = bus_matchmaker_get_rules (matchmaker, i);
 
-      link = _dbus_list_get_first_link (rules);
-      while (link != NULL)
-        {
-          BusMatchRule *rule;
-          DBusList *next;
-
-          rule = link->data;
-          next = _dbus_list_get_next_link (rules, link);
-
-          if (rule->matches_go_to == disconnected)
-            {
-              bus_matchmaker_remove_rule_link (rules, link);
-            }
-          else if (((rule->flags & BUS_MATCH_SENDER) && *rule->sender == ':') ||
-                   ((rule->flags & BUS_MATCH_DESTINATION) && *rule->destination == ':'))
-            {
-              /* The rule matches to/from a base service, see if it's the
-               * one being disconnected, since we know this service name
-               * will never be recycled.
-               */
-              const char *name;
-
-              name = bus_connection_get_name (disconnected);
-              _dbus_assert (name != NULL); /* because we're an active connection */
-
-              if (((rule->flags & BUS_MATCH_SENDER) &&
-                   strcmp (rule->sender, name) == 0) ||
-                  ((rule->flags & BUS_MATCH_DESTINATION) &&
-                   strcmp (rule->destination, name) == 0))
-                {
-                  bus_matchmaker_remove_rule_link (rules, link);
-                }
-            }
-
-          link = next;
-        }
+      rule_list_remove_by_connection (rules, disconnected);
     }
 }
 
-- 
1.6.3.3