[asterisk-commits] trunk r24707 - in /trunk: ./ apps/app_queue.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu May 4 09:38:33 MST 2006


Author: tilghman
Date: Thu May  4 11:38:32 2006
New Revision: 24707

URL: http://svn.digium.com/view/asterisk?rev=24707&view=rev
Log:
Merged revisions 24706 via svnmerge from 
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

........

Modified:
    trunk/   (props changed)
    trunk/apps/app_queue.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?rev=24707&r1=24706&r2=24707&view=diff
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Thu May  4 11:38:32 2006
@@ -306,7 +306,8 @@
 	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 @@
 	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 @@
 				/* 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 @@
 							}
 						} 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



More information about the asterisk-commits mailing list