[asterisk-commits] rmudgett: branch rmudgett/call_waiting r251135 - /team/rmudgett/call_waiting/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 5 21:10:02 CST 2010


Author: rmudgett
Date: Fri Mar  5 21:09:58 2010
New Revision: 251135

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=251135
Log:
1) Factor in HAVE_PRI_SERVICE_MESSAGES to the congestion device state.

2) Make sure that the database record does not exist before putting a new
value into it.

3) Make sure that the congestion device state is correct when
sig_pri_hangup() is called.

Modified:
    team/rmudgett/call_waiting/channels/chan_dahdi.c
    team/rmudgett/call_waiting/channels/sig_pri.c

Modified: team/rmudgett/call_waiting/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/call_waiting/channels/chan_dahdi.c?view=diff&rev=251135&r1=251134&r2=251135
==============================================================================
--- team/rmudgett/call_waiting/channels/chan_dahdi.c (original)
+++ team/rmudgett/call_waiting/channels/chan_dahdi.c Fri Mar  5 21:09:58 2010
@@ -2904,7 +2904,12 @@
 		if (pri->pvts[idx] && !pri->pvts[idx]->no_b_channel) {
 			/* This is a B channel interface. */
 			++num_b_chans;
-			if (pri->pvts[idx]->owner) {
+			if (pri->pvts[idx]->owner
+#if defined(HAVE_PRI_SERVICE_MESSAGES)
+				/* Out-of-service B channels are "in-use". */
+				&& pri->pvts[idx]->service_status
+#endif	/* defined(HAVE_PRI_SERVICE_MESSAGES) */
+				) {
 				++in_use;
 			}
 			if (!pri->pvts[idx]->inalarm) {
@@ -14107,19 +14112,23 @@
 			switch(changestatus) {
 			case 0: /* enable */
 				/* Near end wants to be in service now. */
+				ast_db_del(db_chan_name, SRVST_DBKEY);
 				*why &= ~SRVST_NEAREND;
-				snprintf(db_answer, sizeof(db_answer), "%s:%u", SRVST_TYPE_OOS, *why);
-				ast_db_put(db_chan_name, SRVST_DBKEY, db_answer);
-				if (!*why) {
-					ast_db_del(db_chan_name, SRVST_DBKEY);
+				if (*why) {
+					snprintf(db_answer, sizeof(db_answer), "%s:%u", SRVST_TYPE_OOS, *why);
+					ast_db_put(db_chan_name, SRVST_DBKEY, db_answer);
+				} else {
+					dahdi_pri_update_span_devstate(tmp->pri);
 				}
 				break;
 			/* case 1:  -- loop */
 			case 2: /* disable */
 				/* Near end wants to be out-of-service now. */
+				ast_db_del(db_chan_name, SRVST_DBKEY);
 				*why |= SRVST_NEAREND;
 				snprintf(db_answer, sizeof(db_answer), "%s:%u", SRVST_TYPE_OOS, *why);
 				ast_db_put(db_chan_name, SRVST_DBKEY, db_answer);
+				dahdi_pri_update_span_devstate(tmp->pri);
 				break;
 			/* case 3:  -- continuity */
 			/* case 4:  -- shutdown */

Modified: team/rmudgett/call_waiting/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/call_waiting/channels/sig_pri.c?view=diff&rev=251135&r1=251134&r2=251135
==============================================================================
--- team/rmudgett/call_waiting/channels/sig_pri.c (original)
+++ team/rmudgett/call_waiting/channels/sig_pri.c Fri Mar  5 21:09:58 2010
@@ -3011,20 +3011,24 @@
 					switch (e->service.changestatus) {
 					case 0: /* in-service */
 						/* Far end wants to be in service now. */
+						ast_db_del(db_chan_name, SRVST_DBKEY);
 						*why &= ~SRVST_FAREND;
-						snprintf(db_answer, sizeof(db_answer), "%s:%u", SRVST_TYPE_OOS,
-							*why);
-						ast_db_put(db_chan_name, SRVST_DBKEY, db_answer);
-						if (!*why) {
-							ast_db_del(db_chan_name, SRVST_DBKEY);
+						if (*why) {
+							snprintf(db_answer, sizeof(db_answer), "%s:%u",
+								SRVST_TYPE_OOS, *why);
+							ast_db_put(db_chan_name, SRVST_DBKEY, db_answer);
+						} else {
+							sig_pri_span_devstate_changed(pri);
 						}
 						break;
 					case 2: /* out-of-service */
 						/* Far end wants to be out-of-service now. */
+						ast_db_del(db_chan_name, SRVST_DBKEY);
 						*why |= SRVST_FAREND;
 						snprintf(db_answer, sizeof(db_answer), "%s:%u", SRVST_TYPE_OOS,
 							*why);
 						ast_db_put(db_chan_name, SRVST_DBKEY, db_answer);
+						sig_pri_span_devstate_changed(pri);
 						break;
 					default:
 						ast_log(LOG_ERROR, "Huh?  changestatus is: %d\n", e->service.changestatus);
@@ -4037,7 +4041,7 @@
 
 int sig_pri_hangup(struct sig_pri_chan *p, struct ast_channel *ast)
 {
-	int res = 0;
+	int res;
 #ifdef SUPPORT_USERUSER
 	const char *useruser = pbx_builtin_getvar_helper(ast, "USERUSERINFO");
 #endif
@@ -4061,48 +4065,43 @@
 	p->exten[0] = '\0';
 	sig_pri_set_dialing(p, 0);
 
-	if (!p->call) {
-		res = 0;
-		goto exit;
-	}
-
 	/* Make sure we have a call (or REALLY have a call in the case of a PRI) */
 	if (!pri_grab(p, p->pri)) {
+		if (p->call) {
+			if (p->alreadyhungup) {
+				ast_log(LOG_DEBUG, "Already hungup...  Calling hangup once, and clearing call\n");
+
+#ifdef SUPPORT_USERUSER
+				pri_call_set_useruser(p->call, useruser);
+#endif
+
+				pri_hangup(p->pri->pri, p->call, -1);
+				p->call = NULL;
+			} else {
+				const char *cause = pbx_builtin_getvar_helper(ast,"PRI_CAUSE");
+				int icause = ast->hangupcause ? ast->hangupcause : -1;
+				ast_log(LOG_DEBUG, "Not yet hungup...  Calling hangup once with icause, and clearing call\n");
+
+#ifdef SUPPORT_USERUSER
+				pri_call_set_useruser(p->call, useruser);
+#endif
+
+				p->alreadyhungup = 1;
+				if (cause) {
+					if (atoi(cause))
+						icause = atoi(cause);
+				}
+				pri_hangup(p->pri->pri, p->call, icause);
+			}
+		}
 		sig_pri_span_devstate_changed(p->pri);
-		if (p->alreadyhungup) {
-			ast_log(LOG_DEBUG, "Already hungup...  Calling hangup once, and clearing call\n");
-
-#ifdef SUPPORT_USERUSER
-			pri_call_set_useruser(p->call, useruser);
-#endif
-
-			pri_hangup(p->pri->pri, p->call, -1);
-			p->call = NULL;
-		} else {
-			const char *cause = pbx_builtin_getvar_helper(ast,"PRI_CAUSE");
-			int icause = ast->hangupcause ? ast->hangupcause : -1;
-			ast_log(LOG_DEBUG, "Not yet hungup...  Calling hangup once with icause, and clearing call\n");
-
-#ifdef SUPPORT_USERUSER
-			pri_call_set_useruser(p->call, useruser);
-#endif
-
-			p->alreadyhungup = 1;
-			if (cause) {
-				if (atoi(cause))
-					icause = atoi(cause);
-			}
-			pri_hangup(p->pri->pri, p->call, icause);
-		}
-		if (res < 0)
-			ast_log(LOG_WARNING, "pri_disconnect failed\n");
 		pri_rel(p->pri);
+		res = 0;
 	} else {
 		ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span);
 		res = -1;
 	}
 
-exit:
 	ast->tech_pvt = NULL;
 	return res;
 }




More information about the asterisk-commits mailing list