Summary:ASTERISK-23547: [patch] app_queue removing callers from queue when reloading
Reporter:Italo Rossi (italorossi)Labels:
Date Opened:2014-03-27 10:08:05Date Closed:2014-04-01 11:52:35
Versions: 11.8.1 Frequency of
Environment:Attachments:( 0) app_queue_fix_realtime_reload_1.8_trunk.patch
Description:If you have only realtime members in queue 'sales', for example, and callers are waiting on this queue, when you do 'module reload app_queue.so' all the callers will be removed with EXITEMPTY reason.

The problem is when we reload app_queue, the function:
static int mark_member_dead(void *obj, void *arg, int flags)
       struct member *member = obj;
       if (!member->dynamic) {
               member->delme = 1;
       return 0;

is called and mark the static AND REALTIME members as dead.

At the same time, the remaining callers on queue are checking if there are available members through the function get_member_status. This functions iterate over all members of the queue and will return 0 if there are available members, or -1 if there's no members available.

If you have one realtime member with status inuse and the queue is configured with leavewhenempty=penalty,invalid, for example, the callers will join this queue and will keep waiting for an available member.
Before the reload, the get_member_status will always return 0, because there is one available member with status inuse, but when you reload the app_queue.so, the realtime member will be removed by mark_member_dead (and kill_dead_members) function and the callers waiting on queue will leave with reason EXITEMPTY because get_member_status doesn't iterate over members (there's no members at this time) and returns -1.

Patch attached.

Review Request: https://reviewboard.asterisk.org/r/3404/