Merged revisions 24706 via svnmerge from
authorTilghman Lesher <tilghman@meg.abyt.es>
Thu, 4 May 2006 16:38:32 +0000 (16:38 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Thu, 4 May 2006 16:38:32 +0000 (16:38 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r24706 | tilghman | 2006-05-04 11:27:20 -0500 (Thu, 04 May 2006) | 2 lines

Bug 7023 - reload should not unpause members

........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@24707 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_queue.c

index 7f8c86a..c657e0c 100644 (file)
@@ -306,7 +306,8 @@ struct member {
        int status;                     /*!< Status of queue member */
        int paused;                     /*!< Are we paused (not accepting calls)? */
        time_t lastcall;                /*!< When last successful call was hungup */
-       int dead;                       /*!< Used to detect members deleted in realtime */
+       unsigned int dead:1;                    /*!< Used to detect members deleted in realtime */
+       unsigned int delme:1;           /*!< Flag to delete entry on reload */
        struct member *next;            /*!< Next member */
 };
 
@@ -3334,7 +3335,7 @@ static void reload_queues(void)
        struct ast_config *cfg;
        char *cat, *tmp;
        struct ast_variable *var;
-       struct member *prev, *cur;
+       struct member *prev, *cur, *newm;
        int new;
        char *general_val = NULL;
        char interface[80];
@@ -3383,12 +3384,10 @@ static void reload_queues(void)
                                /* Re-initialize the queue, and clear statistics */
                                init_queue(q);
                                clear_queue(q);
-                               free_members(q, 0);
-                               prev = q->members;
-                               if (prev) {
-                                       /* find the end of any dynamic members */
-                                       while(prev->next)
-                                               prev = prev->next;
+                               for (cur = q->members; cur; cur = cur->next) {
+                                       if (!cur->dynamic) {
+                                               cur->delme = 1;
+                                       }
                                }
                                for (var = ast_variable_browse(cfg, cat); var; var = var->next) {
                                        if (!strcasecmp(var->name, "member")) {
@@ -3403,18 +3402,52 @@ static void reload_queues(void)
                                                        }
                                                } else
                                                        penalty = 0;
-                                               cur = create_queue_member(interface, penalty, 0);
+
+                                               /* Find the old position in the list */
+                                               for (prev = NULL, cur = q->members; cur; prev = cur, cur = cur->next) {
+                                                       if (!strcmp(cur->interface, interface)) {
+                                                               break;
+                                                       }
+                                               }
+
+                                               newm = create_queue_member(interface, penalty, cur ? cur->paused : 0);
+
                                                if (cur) {
-                                                       if (prev)
-                                                               prev->next = cur;
-                                                       else
-                                                               q->members = cur;
-                                                       prev = cur;
+                                                       /* Delete it now */
+                                                       newm->next = cur->next;
+                                                       if (prev) {
+                                                               prev->next = newm;
+                                                       } else {
+                                                               q->members = newm;
+                                                       }
+                                                       free(cur);
+                                               } else {
+                                                       newm->next = q->members;
+                                                       q->members = newm;
                                                }
                                        } else {
                                                queue_set_param(q, var->name, var->value, var->lineno, 1);
                                        }
                                }
+
+                               /* Free remaining members marked as delme */
+                               for (prev = NULL, newm = NULL, cur = q->members; cur; prev = cur, cur = cur->next) {
+                                       if (newm) {
+                                               free(newm);
+                                               newm = NULL;
+                                       }
+
+                                       if (cur->delme) {
+                                               if (prev) {
+                                                       prev->next = cur->next;
+                                                       newm = cur;
+                                               } else {
+                                                       q->members = cur->next;
+                                                       newm = cur;
+                                               }
+                                       }
+                               }
+
                                if (new) {
                                        AST_LIST_INSERT_HEAD(&queues, q, list);
                                } else