diff options
author | Konrad Lipinski <konrad.l@samsung.com> | 2016-08-17 14:27:55 +0200 |
---|---|---|
committer | Konrad Lipinski <konrad.l@samsung.com> | 2016-08-18 12:50:26 +0200 |
commit | d8be3fe28ad41f9ed572359440c9889a8a4a0638 (patch) | |
tree | 85ed477a0e3d43248c4aed69c25effac265d1002 | |
parent | 2926011c5f3b5bcc07af65108a1e8b13cd9fd3c3 (diff) | |
download | dbus-d8be3fe28ad41f9ed572359440c9889a8a4a0638.tar.gz dbus-d8be3fe28ad41f9ed572359440c9889a8a4a0638.tar.bz2 dbus-d8be3fe28ad41f9ed572359440c9889a8a4a0638.zip |
omit standard match iff sender=org.freedesktop.DBus
Change-Id: Ib8a1c138983124a2597b0c700f5c6a2c7dd4744e
-rw-r--r-- | dbus/dbus-transport-kdbus.c | 98 |
1 files changed, 36 insertions, 62 deletions
diff --git a/dbus/dbus-transport-kdbus.c b/dbus/dbus-transport-kdbus.c index 2fa932e8..b82e4d0a 100644 --- a/dbus/dbus-transport-kdbus.c +++ b/dbus/dbus-transport-kdbus.c @@ -1369,33 +1369,6 @@ strcmp_existing (const char *str1, const char *str2) } static dbus_bool_t -kernel_match_needed (MatchRule *rule) -{ - int message_type; - - /* Allow only NameOwnerChanged member */ - if (strcmp_existing (_match_rule_get_member (rule), "NameOwnerChanged") != 0) - return FALSE; - - /* Allow only signals */ - message_type = _match_rule_get_message_type (rule); - if (message_type != DBUS_MESSAGE_TYPE_INVALID && message_type != DBUS_MESSAGE_TYPE_SIGNAL) - return FALSE; - - /* Check if from DBus */ - if (strcmp_existing (_match_rule_get_sender (rule), DBUS_SERVICE_DBUS) != 0) - return FALSE; - - if (strcmp_existing (_match_rule_get_interface (rule), DBUS_INTERFACE_DBUS) != 0) - return FALSE; - - if (strcmp_existing (_match_rule_get_path (rule), DBUS_PATH_DBUS) != 0) - return FALSE; - - return TRUE; -} - -static dbus_bool_t is_bloom_needed (MatchRule *rule) { int rule_int; @@ -1511,6 +1484,7 @@ add_match_kdbus (DBusTransportKdbus *transport, int ret; rule_cookie = match_rule_get_cookie (rule); + rule_sender = _match_rule_get_sender (rule); /* * First check if it is org.freedesktop.DBus's NameOwnerChanged or any @@ -1518,45 +1492,46 @@ add_match_kdbus (DBusTransportKdbus *transport, * because it must be converted to special kdbus rule (kdbus has separate rules * for kdbus (kernel) generated broadcasts). */ - if (kernel_match_needed (rule)) + if (!strcmp_existing (rule_sender, DBUS_SERVICE_DBUS)) { - ret = _kdbus_add_match_name_change (transport->kdbus, - 0, - rule_cookie, - KDBUS_MATCH_ID_ANY, - 0, - KDBUS_MATCH_ID_ANY, - 0); - if (0 != ret) - { - _dbus_verbose ("Failed adding match rule for name removal for daemon, error: %d, %s\n", - ret, _dbus_strerror (ret)); - return FALSE; - } + int message_type = _match_rule_get_message_type (rule); - ret = _kdbus_add_match_id_change (transport->kdbus, - 0, - rule_cookie, - KDBUS_MATCH_ID_ANY, - 0); - if (0 != ret) + if ((DBUS_MESSAGE_TYPE_INVALID == message_type || DBUS_MESSAGE_TYPE_SIGNAL == message_type) + && !strcmp_existing (_match_rule_get_member (rule), "NameOwnerChanged") + && !strcmp_existing (_match_rule_get_interface (rule), DBUS_INTERFACE_DBUS) + && !strcmp_existing (_match_rule_get_path (rule), DBUS_PATH_DBUS)) { - _dbus_verbose ("Failed adding match rule for adding id for daemon, error: %d, %s\n", - ret, _dbus_strerror (ret)); - return FALSE; - } + ret = _kdbus_add_match_name_change (transport->kdbus, + 0, + rule_cookie, + KDBUS_MATCH_ID_ANY, + 0, + KDBUS_MATCH_ID_ANY, + 0); + if (0 != ret) + { + _dbus_verbose ("Failed adding match rule for name removal for daemon, error: %d, %s\n", + ret, _dbus_strerror (ret)); + return FALSE; + } - _dbus_verbose ("Added match rule for kernel correctly.\n"); + ret = _kdbus_add_match_id_change (transport->kdbus, + 0, + rule_cookie, + KDBUS_MATCH_ID_ANY, + 0); + if (0 != ret) + { + _dbus_verbose ("Failed adding match rule for adding id for daemon, error: %d, %s\n", + ret, _dbus_strerror (ret)); + return FALSE; + } -/* - * In case all of sender, interface and path are NULL, the rule - * says simply about NameHasOwner signal from any object, any interface, any sender. - * So, we need to consider that. - * Otherwise, our job is finished here. - */ - if (_match_rule_get_sender (rule) != NULL - || _match_rule_get_interface (rule) != NULL - || _match_rule_get_path (rule) != NULL) + _dbus_verbose ("Added match rule for kernel correctly.\n"); + } + + /* Sender=DBUS_SERVICE_DBUS matches (as opposed to wildcard sender) need no standard rule. */ + if (rule_sender) return TRUE; } @@ -1567,7 +1542,6 @@ add_match_kdbus (DBusTransportKdbus *transport, need_bloom = is_bloom_needed (rule); - rule_sender = _match_rule_get_sender (rule); if (rule_sender != NULL) { DBusString str; |