[svn-commits] eliel: branch eliel/per_member_wrapuptime r188506 - /team/eliel/per_member_wr...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Apr 15 08:07:32 CDT 2009


Author: eliel
Date: Wed Apr 15 08:07:23 2009
New Revision: 188506

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=188506
Log:
Fix issues pointed by mmichelson on reviewboard.

- Use + or - to describe an offset when setting the wrapuptime (Remove 'Absolute' and
  'Offset' from the AMI action).
- Simplify all the ast_strlen_zero() calls that were not necessary.
- Remember to ao2_ref(,-1) the members when using interface_exists().


Modified:
    team/eliel/per_member_wrapuptime/apps/app_queue.c

Modified: team/eliel/per_member_wrapuptime/apps/app_queue.c
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/per_member_wrapuptime/apps/app_queue.c?view=diff&rev=188506&r1=188505&r2=188506
==============================================================================
--- team/eliel/per_member_wrapuptime/apps/app_queue.c (original)
+++ team/eliel/per_member_wrapuptime/apps/app_queue.c Wed Apr 15 08:07:23 2009
@@ -4417,6 +4417,7 @@
 				} else {
 					mem->current_wrapuptime += offset;
 				}
+				ao2_ref(mem, -1);
 			}
 		}
 		ao2_unlock(q);
@@ -6787,22 +6788,16 @@
  */
 static int manager_queue_member_wrapuptime(struct mansession *s, const struct message *m)
 {
-	const char *interface, *offset, *static_value, *queue, *absolute;
-	int default_wrapuptime = 0, is_absolute = 0, value;
+	const char *interface, *wrapuptime, *static_value, *queue;
+	int default_wrapuptime = 0, is_absolute = 1, value;
 
 	interface = astman_get_header(m, "Interface");
 	queue = astman_get_header(m, "Queue");
-	offset = astman_get_header(m, "Offset");
-	absolute = astman_get_header(m, "Absolute");
+	wrapuptime = astman_get_header(m, "Wrapuptime");
 	static_value = astman_get_header(m, "Static");
 
-	if (ast_strlen_zero(interface) || (ast_strlen_zero(offset) && ast_strlen_zero(absolute))) {
-		astman_send_error(s, m, "Need 'Interface' and ('Offset' or 'Absolute') parameters.");
-		return -1;
-	}
-
-	if (ast_strlen_zero(absolute) && ast_strlen_zero(offset)) {
-		astman_send_error(s, m, "Only specify 'Offset' or 'Absolute'.");
+	if (ast_strlen_zero(interface) || ast_strlen_zero(wrapuptime)) {
+		astman_send_error(s, m, "Need 'Interface' and 'Wrapuptime' parameters.");
 		return -1;
 	}
 
@@ -6811,12 +6806,11 @@
 		default_wrapuptime = ast_true(static_value);
 	}
 
-	if (ast_strlen_zero(absolute)) {
-		is_absolute = 1;
-		value = atoi(absolute);
-	} else {
-		value = atoi(offset);
-	}
+	if (strchr(wrapuptime, '+') || strchr(wrapuptime, '-')) {
+		is_absolute = 0;
+	}
+
+	value = atoi(wrapuptime);
 
 	set_member_wrapuptime(queue, interface, value, default_wrapuptime, is_absolute);
 
@@ -7170,7 +7164,7 @@
 static char *handle_queue_set_member_wrapuptime(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	char *queuename = NULL, *interface, *ret;
-	int wrapuptime, member_default = 0;
+	int wrapuptime, member_default = 0, absolute = 1;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -7202,7 +7196,12 @@
 		member_default = 1;
 	}
 
-	if (set_member_wrapuptime(queuename, interface, wrapuptime, !member_default, 1)) {
+	/* the passed value is an offset or an absolute value? */
+	if (strchr(a->argv[3], '+') || strchr(a->argv[3], '-')) {
+		absolute = 0;
+	}
+
+	if (set_member_wrapuptime(queuename, interface, wrapuptime, member_default, absolute)) {
 		ast_cli(a->fd, "Failed to set wrapuptime on interface '%s'", interface);
 		ret = CLI_FAILURE;
 	} else {




More information about the svn-commits mailing list