[asterisk-commits] tzafrir: branch 1.6.2 r278524 - /branches/1.6.2/channels/chan_dahdi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 21 13:22:33 CDT 2010


Author: tzafrir
Date: Wed Jul 21 13:22:25 2010
New Revision: 278524

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=278524
Log:
Fix invalid test for rxisoffhook in FXO channels

This fixes some cases of no outgoing calls on FXO before an incoming call.

Remove an unnecessary testing of an "off-hook" bit from DAHDI for FXO
(KS/GS) channels.In some cases the bit would not be initialized properly
before the first inbound call and thus prevent an outgoing call.

If those tests are actually required by anybody, they should define
DAHDI_CHECK_HOOKSTATE in channels/sig_analog.c .

(closes issue #14577)
Reported by: jkroon
Patches:
       asterisk_chan_dahdi_hookstate_fix.diff uploaded by frawd (license 610)
Tested by: frawd

Review: https://reviewboard.asterisk.org/r/699/



Modified:
    branches/1.6.2/channels/chan_dahdi.c

Modified: branches/1.6.2/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/channels/chan_dahdi.c?view=diff&rev=278524&r1=278523&r2=278524
==============================================================================
--- branches/1.6.2/channels/chan_dahdi.c (original)
+++ branches/1.6.2/channels/chan_dahdi.c Wed Jul 21 13:22:25 2010
@@ -10812,10 +10812,10 @@
 				return 1;
 		}
 #endif
-		if (!(p->radio || (p->oprmode < 0)))
+
+		/* Trust hook state */
+		if (p->sig && !(p->radio || (p->oprmode < 0)))
 		{
-			if (!p->sig || (p->sig == SIG_FXSLS))
-				return 1;
 			/* Check hook state */
 			if (p->subs[SUB_REAL].dfd > -1) {
 				memset(&par, 0, sizeof(par));
@@ -10825,28 +10825,30 @@
 				res = 0;
 				par.rxisoffhook = 0;
 			}
+
 			if (res) {
 				ast_log(LOG_WARNING, "Unable to check hook state on channel %d: %s\n", p->channel, strerror(errno));
-			} else if ((p->sig == SIG_FXSKS) || (p->sig == SIG_FXSGS)) {
-				/* When "onhook" that means no battery on the line, and thus
-				  it is out of service..., if it's on a TDM card... If it's a channel
-				  bank, there is no telling... */
+			}
+			else if ((p->sig != SIG_FXSKS) && (p->sig != SIG_FXSGS) && (p->sig != SIG_FXSLS)) {
+				if (par.rxisoffhook) {
+					ast_debug(1, "Channel %d off hook, can't use\n", p->channel);
+					/* Not available when the other end is off hook */
+					return 0;
+				}
+			}
+#ifdef DAHDI_CHECK_HOOKSTATE
+			} else { /* FXO channel case (SIG_FXS--) */
+				/* Channel bank (using CAS), "onhook" does not necessarily means out of service, so return 1 */
 				if (par.rxbits > -1)
 					return 1;
+				/* TDM FXO card, "onhook" means out of service (no battery on the line) */
 				if (par.rxisoffhook)
 					return 1;
 				else
 					return 0;
-			} else if (par.rxisoffhook) {
-				ast_debug(1, "Channel %d off hook, can't use\n", p->channel);
-				/* Not available when the other end is off hook */
-#ifdef DAHDI_CHECK_HOOKSTATE
-				return 0;
-#else
-				return 1;
-#endif
-			}
-		}
+#endif
+		}
+
 		return 1;
 	}
 




More information about the asterisk-commits mailing list