match_rule_matches (BusMatchRule *rule,
DBusConnection *sender,
DBusConnection *addressed_recipient,
- DBusMessage *message)
+ DBusMessage *message,
+ BusMatchFlags already_matched)
{
+ int flags;
+
/* All features of the match rule are AND'd together,
* so FALSE if any of them don't match.
*/
* or for addressed_recipient may mean a message with no
* specific recipient (i.e. a signal)
*/
-
- if (rule->flags & BUS_MATCH_MESSAGE_TYPE)
+
+ /* Don't bother re-matching features we've already checked implicitly. */
+ flags = rule->flags & (~already_matched);
+
+ if (flags & BUS_MATCH_MESSAGE_TYPE)
{
_dbus_assert (rule->message_type != DBUS_MESSAGE_TYPE_INVALID);
return FALSE;
}
- if (rule->flags & BUS_MATCH_INTERFACE)
+ if (flags & BUS_MATCH_INTERFACE)
{
const char *iface;
return FALSE;
}
- if (rule->flags & BUS_MATCH_MEMBER)
+ if (flags & BUS_MATCH_MEMBER)
{
const char *member;
return FALSE;
}
- if (rule->flags & BUS_MATCH_SENDER)
+ if (flags & BUS_MATCH_SENDER)
{
_dbus_assert (rule->sender != NULL);
}
}
- if (rule->flags & BUS_MATCH_DESTINATION)
+ if (flags & BUS_MATCH_DESTINATION)
{
const char *destination;
}
}
- if (rule->flags & BUS_MATCH_PATH)
+ if (flags & BUS_MATCH_PATH)
{
const char *path;
return FALSE;
}
- if (rule->flags & BUS_MATCH_ARGS)
+ if (flags & BUS_MATCH_ARGS)
{
int i;
DBusMessageIter iter;
#endif
if (match_rule_matches (rule,
- sender, addressed_recipient, message))
+ sender, addressed_recipient, message,
+ BUS_MATCH_MESSAGE_TYPE))
{
_dbus_verbose ("Rule matched\n");
_dbus_assert (rule != NULL);
/* We can't test sender/destination rules since we pass NULL here */
- matched = match_rule_matches (rule, NULL, NULL, message);
+ matched = match_rule_matches (rule, NULL, NULL, message, 0);
if (matched != expected_to_match)
{