Fix a bug where resources were not found due to hashing on the priority itself.

........

Merged revisions 383266 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@383267 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Joshua Colp
2013-03-16 15:15:44 +00:00
parent 49e3489cac
commit 2f89b7a6eb

View File

@@ -831,10 +831,10 @@ static int xmpp_resource_hash(const void *obj, const int flags)
/*! \brief Comparator function for XMPP resource */
static int xmpp_resource_cmp(void *obj, void *arg, int flags)
{
struct ast_xmpp_resource *resource1 = obj, *resource2 = arg;
struct ast_xmpp_resource *resource1 = obj;
const char *resource = arg;
return !strcmp(resource1->resource, flags & OBJ_KEY ? resource : resource2->resource) ? CMP_MATCH | CMP_STOP : 0;
return !strcmp(resource1->resource, resource) ? CMP_MATCH | CMP_STOP : 0;
}
/*! \brief Destructor callback function for XMPP buddy */
@@ -1681,7 +1681,7 @@ static int xmpp_status_exec(struct ast_channel *chan, const char *data)
return -1;
}
if (ast_strlen_zero(jid.resource) || !(resource = ao2_find(buddy->resources, jid.resource, OBJ_KEY))) {
if (ast_strlen_zero(jid.resource) || !(resource = ao2_callback(buddy->resources, 0, xmpp_resource_cmp, jid.resource))) {
resource = ao2_callback(buddy->resources, OBJ_NODATA, xmpp_resource_immediate, NULL);
}
@@ -1752,7 +1752,7 @@ static int acf_jabberstatus_read(struct ast_channel *chan, const char *name, cha
return -1;
}
if (ast_strlen_zero(jid.resource) || !(resource = ao2_find(buddy->resources, jid.resource, OBJ_KEY))) {
if (ast_strlen_zero(jid.resource) || !(resource = ao2_callback(buddy->resources, 0, xmpp_resource_cmp, jid.resource))) {
resource = ao2_callback(buddy->resources, OBJ_NODATA, xmpp_resource_immediate, NULL);
}
@@ -2480,7 +2480,7 @@ static int xmpp_client_service_discovery_result_hook(void *data, ikspak *pak)
return IKS_FILTER_EAT;
}
if (!(resource = ao2_find(buddy->resources, pak->from->resource, OBJ_KEY))) {
if (!(resource = ao2_callback(buddy->resources, 0, xmpp_resource_cmp, pak->from->resource))) {
ao2_ref(buddy, -1);
return IKS_FILTER_EAT;
}
@@ -3273,7 +3273,7 @@ static int xmpp_pak_presence(struct ast_xmpp_client *client, struct ast_xmpp_cli
ao2_lock(buddy->resources);
if (!(resource = ao2_find(buddy->resources, pak->from->resource, OBJ_KEY | OBJ_NOLOCK))) {
if (!(resource = ao2_callback(buddy->resources, OBJ_NOLOCK, xmpp_resource_cmp, pak->from->resource))) {
/* Only create the new resource if it is not going away - in reality this should not happen */
if (status != STATUS_DISAPPEAR) {
if (!(resource = ao2_alloc(sizeof(*resource), xmpp_resource_destructor))) {