[asterisk-dev] Member order in RealTime dynamic queues

Mark Michelson mmichelson at digium.com
Mon Jun 23 09:43:32 CDT 2008


Saúl Ibarra wrote:
> I've been playing around a little with the app_queue.c and I still
> don't understand one thing :-/ the function member_hash_fn returns
> correct hash order, but my dynamic members (SIP/7881 to SIP/886) are
> always ordered like this in Asterisk's memory:
> 
> 7881
> 7885
> 7882
> 7886
> 7883
> 7884
> 
> The login order doesn't seem to affect this order, as I always get the same :-O
> Any clues on this?
> 
> Thanks in advance!
> 

The hash is based on the "interface" associated with a queue member. There is a 
way you can edit the code such that you can predict the order of queue members.
In the function init_queue(), look for the following line:

q->members = ao2_container_alloc(37, member_hash_fn, member_cmp_fn);

If you change the 37 to a 1, then the result will be that the hash table for 
that queue's members will have one bucket instead of 37. Since all members will 
hash to the same bucket, you essentially will be using a linked list for queue 
members. Members would then be stored in the order in which they are parsed in 
the configuration.

Mark Michelson



More information about the asterisk-dev mailing list