[asterisk-commits] murf: branch 1.2 r65172 - in /branches/1.2: ./ apps/ include/asterisk/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri May 18 13:56:20 MST 2007


Author: murf
Date: Fri May 18 15:56:20 2007
New Revision: 65172

URL: http://svn.digium.com/view/asterisk?view=rev&rev=65172
Log:
This update will fix the situation that occurs as described by 9717, where when several targets are specified for a dial, if any one them reports FAIL, the whole call gets FAIL, even though others were ringing OK. I rearranged the priorities, so that a new disposition, NULL, is at the lowest level, and the disposition get init'd to NULL. Then, next up is FAIL, and next up is BUSY, then NOANSWER, then ANSWERED. All the related set routines will only do so if the disposition value to be set to is greater than what's already there. This gives the intended effect. So, if all the targets are busy, you'd get BUSY for the call disposition. If all get BUSY, but one, and that one rings is not answered, you get NOANSWER. If by some freak of nature, the NULL value doesn't get overridden, then the disp2str routine will report NOANSWER as before.

Modified:
    branches/1.2/apps/app_dial.c
    branches/1.2/cdr.c
    branches/1.2/include/asterisk/cdr.h

Modified: branches/1.2/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/apps/app_dial.c?view=diff&rev=65172&r1=65171&r2=65172
==============================================================================
--- branches/1.2/apps/app_dial.c (original)
+++ branches/1.2/apps/app_dial.c Fri May 18 15:56:20 2007
@@ -678,6 +678,7 @@
 			if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP))) {
 				/* Got hung up */
 				*to=-1;
+				ast_cdr_noanswer(in->cdr);
 				strcpy(status, "CANCEL");
 				if (f)
 					ast_frfree(f);
@@ -691,6 +692,7 @@
 						if (option_verbose > 3)
 							ast_verbose(VERBOSE_PREFIX_3 "User hit %c to disconnect call.\n", f->subclass);
 						*to=0;
+						ast_cdr_noanswer(in->cdr);
 						*result = f->subclass;
 						strcpy(status, "CANCEL");
 						ast_frfree(f);
@@ -703,6 +705,7 @@
 					if (option_verbose > 3)
 						ast_verbose(VERBOSE_PREFIX_3 "User hit %c to disconnect call.\n", f->subclass);
 					*to=0;
+					ast_cdr_noanswer(in->cdr);
 					strcpy(status, "CANCEL");
 					ast_frfree(f);
 					return NULL;
@@ -727,6 +730,10 @@
 		}
 		if (!*to && (option_verbose > 2))
 			ast_verbose( VERBOSE_PREFIX_3 "Nobody picked up in %d ms\n", orig);
+		if (!*to || ast_check_hangup(in)) {
+			ast_cdr_noanswer(in->cdr);
+		}
+		
 	}
 
 	return peer;

Modified: branches/1.2/cdr.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/cdr.c?view=diff&rev=65172&r1=65171&r2=65172
==============================================================================
--- branches/1.2/cdr.c (original)
+++ branches/1.2/cdr.c Fri May 18 15:56:20 2007
@@ -528,6 +528,22 @@
 	}
 }
 
+void ast_cdr_noanswer(struct ast_cdr *cdr)
+{
+	char *chan; 
+
+	while (cdr) {
+		chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
+		if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
+			ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
+		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
+			if (cdr->disposition < AST_CDR_NOANSWER)
+				cdr->disposition = AST_CDR_NOANSWER;
+		}
+		cdr = cdr->next;
+	}
+}
+
 int ast_cdr_disposition(struct ast_cdr *cdr, int cause)
 {
 	int res = 0;
@@ -638,7 +654,7 @@
 			ast_copy_string(cdr->clid, tmp, sizeof(cdr->clid));
 			ast_copy_string(cdr->src, num ? num : "", sizeof(cdr->src));
 
-			cdr->disposition = (c->_state == AST_STATE_UP) ?  AST_CDR_ANSWERED : AST_CDR_NOANSWER;
+			cdr->disposition = (c->_state == AST_STATE_UP) ?  AST_CDR_ANSWERED : AST_CDR_NULL;
 			cdr->amaflags = c->amaflags ? c->amaflags :  ast_default_amaflags;
 			ast_copy_string(cdr->accountcode, c->accountcode, sizeof(cdr->accountcode));
 			/* Destination information */
@@ -671,6 +687,8 @@
 char *ast_cdr_disp2str(int disposition)
 {
 	switch (disposition) {
+	case AST_CDR_NULL:
+		return "NO ANSWER"; /* by default, for backward compatibility */
 	case AST_CDR_NOANSWER:
 		return "NO ANSWER";
 	case AST_CDR_FAILED:
@@ -862,7 +880,7 @@
 			cdr->billsec = 0;
 			cdr->duration = 0;
 			ast_cdr_start(cdr);
-			cdr->disposition = AST_CDR_NOANSWER;
+			cdr->disposition = AST_CDR_NULL;
 		}
 			
 		cdr = cdr->next;

Modified: branches/1.2/include/asterisk/cdr.h
URL: http://svn.digium.com/view/asterisk/branches/1.2/include/asterisk/cdr.h?view=diff&rev=65172&r1=65171&r2=65172
==============================================================================
--- branches/1.2/include/asterisk/cdr.h (original)
+++ branches/1.2/include/asterisk/cdr.h Fri May 18 15:56:20 2007
@@ -30,9 +30,10 @@
 #define AST_CDR_FLAG_CHILD			(1 << 3)
 #define AST_CDR_FLAG_POST_DISABLED		(1 << 4)
 
-#define AST_CDR_NOANSWER			(1 << 0)
+#define AST_CDR_NULL                0
+#define AST_CDR_FAILED				(1 << 0)
 #define AST_CDR_BUSY				(1 << 1)
-#define AST_CDR_FAILED				(1 << 2)
+#define AST_CDR_NOANSWER			(1 << 2)
 #define AST_CDR_ANSWERED			(1 << 3)
 
 /*! AMA Flags */
@@ -169,6 +170,13 @@
  */
 extern void ast_cdr_answer(struct ast_cdr *cdr);
 
+/*! A call wasn't answered */
+/*!
+ * \param cdr the cdr you wish to associate with the call
+ * Marks the channel disposition as "NO ANSWER"
+ */
+extern void ast_cdr_noanswer(struct ast_cdr *cdr);
+
 /*! Busy a call */
 /*!
  * \param cdr the cdr you wish to associate with the call



More information about the asterisk-commits mailing list