Index: apps/app_queue.c =================================================================== --- apps/app_queue.c (revision 101580) +++ apps/app_queue.c (working copy) @@ -365,6 +365,7 @@ struct call_queue *lastqueue; /*!< Last queue we received a call */ unsigned int dead:1; /*!< Used to detect members deleted in realtime */ unsigned int delme:1; /*!< Flag to delete entry on reload */ + int rt_uniqueid; /*!< Unique id of realtime member entry */ }; struct member_interface { @@ -1279,23 +1280,29 @@ } } -static void rt_handle_member_record(struct call_queue *q, char *interface, const char *membername, const char *penalty_str, const char *paused_str, const char* state_interface) +static void rt_handle_member_record(struct call_queue *q, char *interface, const char *rt_uniqueid_str, const char *membername, const char *penalty_str, const char *paused_str, const char* state_interface) { struct member *m, tmpmem; int penalty = 0; int paused = 0; + int rt_uniqueid = 0; - if (penalty_str) { + if (!ast_strlen_zero(penalty_str)) { penalty = atoi(penalty_str); if (penalty < 0) penalty = 0; } - if (paused_str) { + if (!ast_strlen_zero(paused_str)) { paused = atoi(paused_str); if (paused < 0) paused = 0; } + if (!ast_strlen_zero(rt_uniqueid_str)) { + rt_uniqueid = atoi(rt_uniqueid_str); + if (rt_uniqueid < 0) + rt_uniqueid = 0; + } /* Find the member, or the place to put a new one. */ ast_copy_string(tmpmem.interface, interface, sizeof(tmpmem.interface)); @@ -1306,6 +1313,7 @@ if ((m = create_queue_member(interface, membername, penalty, paused, state_interface))) { m->dead = 0; m->realtime = 1; + m->rt_uniqueid = rt_uniqueid; add_to_interfaces(m->state_interface); ao2_link(q->members, m); ao2_ref(m, -1); @@ -1481,6 +1489,7 @@ while ((interface = ast_category_browse(member_config, interface))) { rt_handle_member_record(q, interface, + ast_variable_retrieve(member_config, interface, "uniqueid"), S_OR(ast_variable_retrieve(member_config, interface, "membername"),interface), ast_variable_retrieve(member_config, interface, "penalty"), ast_variable_retrieve(member_config, interface, "paused"), @@ -1550,20 +1559,17 @@ static int update_realtime_member_field(struct member *mem, const char *queue_name, const char *field, const char *value) { - struct ast_variable *var; + char rt_uniqueid_str[20]; int ret = -1; - if (!(var = ast_load_realtime("queue_members", "interface", mem->interface, "queue_name", queue_name, NULL))) + if (!mem->rt_uniqueid) return ret; - while (var) { - if (!strcmp(var->name, "uniqueid")) - break; - var = var->next; - } - if (var && !ast_strlen_zero(var->value)) { - if ((ast_update_realtime("queue_members", "uniqueid", var->value, field, value, NULL)) > -1) - ret = 0; - } + + snprintf(rt_uniqueid_str, sizeof(rt_uniqueid_str), "%ld", (long)(mem->rt_uniqueid)); + + if ((ast_update_realtime("queue_members", "uniqueid", rt_uniqueid_str, field, value, NULL)) > -1) + ret = 0; + return ret; } @@ -1592,6 +1598,7 @@ while ((interface = ast_category_browse(member_config, interface))) { rt_handle_member_record(q, interface, + ast_variable_retrieve(member_config, interface, "uniqueid"), S_OR(ast_variable_retrieve(member_config, interface, "membername"), interface), ast_variable_retrieve(member_config, interface, "penalty"), ast_variable_retrieve(member_config, interface, "paused"),