# HG changeset patch # User Paul Aurich # Date 1246572201 0 # Node ID ea9df9bfa9212f273dbbdff0c1bf4351d18d857a # Parent c408e4dc310163508c3f0d5950e30cc1f2997677 If get_info_for_jid is passed a full JID, don't spam that JID with IQs. Looping over all the resources while using the passed-in JID as the to address was causing us to generate O(N) queries to a member of a MUC (where N is the number of people in the room). diff -r c408e4dc3101 -r ea9df9bfa921 libpurple/protocols/jabber/buddy.c --- a/libpurple/protocols/jabber/buddy.c Thu Jul 02 21:55:15 2009 +0000 +++ b/libpurple/protocols/jabber/buddy.c Thu Jul 02 22:03:21 2009 +0000 @@ -1725,6 +1725,7 @@ GList *resources; JabberBuddy *jb; JabberBuddyInfo *jbi; + const char *slash; gboolean is_bare_jid; jb = jabber_buddy_find(js, jid, TRUE); @@ -1733,7 +1734,8 @@ if(!jb) return; - is_bare_jid = (strchr(jid, '/') == NULL); + slash = strchr(jid, '/'); + is_bare_jid = (slash == NULL); jbi = g_new0(JabberBuddyInfo, 1); jbi->jid = g_strdup(jid); @@ -1753,10 +1755,19 @@ jabber_iq_send(iq); - for(resources = jb->resources; resources; resources = resources->next) - { - JabberBuddyResource *jbr = resources->data; - dispatch_queries_for_resource(js, jbi, is_bare_jid, jid, jbr); + if (is_bare_jid) { + for(resources = jb->resources; resources; resources = resources->next) { + JabberBuddyResource *jbr = resources->data; + dispatch_queries_for_resource(js, jbi, is_bare_jid, jid, jbr); + } + } else { + JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, slash + 1); + if (jbr) + dispatch_queries_for_resource(js, jbi, is_bare_jid, jid, jbr); + else + purple_debug_warning("jabber", "jabber_buddy_get_info_for_jid() " + "was passed JID %s, but there is no corresponding " + "JabberBuddyResource!\n", jid); } if (!jb->resources && is_bare_jid) {