[asterisk-commits] rizzo: branch rizzo/astobj2 r47447 - /team/rizzo/astobj2/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Nov 10 10:54:50 MST 2006


Author: rizzo
Date: Fri Nov 10 11:54:50 2006
New Revision: 47447

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47447
Log:
flatten a very large function


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=47447&r1=47446&r2=47447
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Fri Nov 10 11:54:50 2006
@@ -15152,50 +15152,51 @@
  */
 static void check_rtp_timeout(struct sip_pvt *sip, time_t t)
 {
-	if (sip->rtp && sip->owner &&
-	    (sip->owner->_state == AST_STATE_UP) &&
-	    !sip->redirip.sin_addr.s_addr) {
-		if (sip->lastrtptx &&
-		    sip->rtpkeepalive &&
-		    (t > sip->lastrtptx + sip->rtpkeepalive)) {
-			/* Need to send an empty RTP packet */
-			sip->lastrtptx = time(NULL);
-			ast_rtp_sendcng(sip->rtp, 0);
-		}
-		if (sip->lastrtprx &&
-		    (sip->rtptimeout || sip->rtpholdtimeout) &&
-		    (t > sip->lastrtprx + sip->rtptimeout)) {
-			/* Might be a timeout now -- see if we're on hold */
-			struct sockaddr_in sin;
-			ast_rtp_get_peer(sip->rtp, &sin);
-			if (sin.sin_addr.s_addr || 
-			    (sip->rtpholdtimeout && 
-			     (t > sip->lastrtprx + sip->rtpholdtimeout))) {
-				/* Needs a hangup */
-				if (sip->rtptimeout) {
-					lock_pvt_and_owner(sip, 0 /* forever */); /* safe, dialoglist is locked */
-					if (sip->owner) {
-						if (!(ast_rtp_get_bridged(sip->rtp))) {
-							ast_log(LOG_NOTICE,
-								"Disconnecting call '%s' for lack of RTP activity in %ld seconds\n",
-								sip->owner->name,
-								(long) (t - sip->lastrtprx));
-							/* Issue a softhangup */
-							ast_softhangup_nolock(sip->owner, AST_SOFTHANGUP_DEV);
-						} else
-							ast_log(LOG_NOTICE, "'%s' will not be disconnected in %ld seconds because it is directly bridged to another RTP stream\n", sip->owner->name, (long) (t - sip->lastrtprx));
-						ast_channel_unlock(sip->owner);
-						/* forget the timeouts for this call, since a hangup
-						   has already been requested and we don't want to
-						   repeatedly request hangups
-						*/
-						sip->rtptimeout = 0;
-						sip->rtpholdtimeout = 0;
-					}
-				}
-			}
-		}
-	}
+	struct sockaddr_in sin;
+
+	if (! (sip->rtp && sip->owner && (sip->owner->_state == AST_STATE_UP) && !sip->redirip.sin_addr.s_addr) )
+		return;
+
+	if (sip->lastrtptx && sip->rtpkeepalive && (t > sip->lastrtptx + sip->rtpkeepalive)) {
+		/* Need to send an empty RTP packet */
+		sip->lastrtptx = time(NULL);
+		ast_rtp_sendcng(sip->rtp, 0);
+	}
+
+	/* XXX probably wrong check if rtptimeout == 0 */
+	if (! (sip->lastrtprx && (sip->rtptimeout || sip->rtpholdtimeout) && (t > sip->lastrtprx + sip->rtptimeout)) )
+		return;
+
+	/* Might be a timeout now -- see if we're on hold */
+	ast_rtp_get_peer(sip->rtp, &sin);
+	if (! (sin.sin_addr.s_addr || (sip->rtpholdtimeout && (t > sip->lastrtprx + sip->rtpholdtimeout))) )
+		return;
+
+	if (!sip->rtptimeout)
+		return;
+
+	lock_pvt_and_owner(sip, 0 /* forever */); /* safe, dialoglist is locked */
+	if (!sip->owner)
+		return;
+
+	if (!(ast_rtp_get_bridged(sip->rtp))) {
+		ast_log(LOG_NOTICE,
+			"Disconnecting call '%s' for lack of RTP activity in %ld seconds\n",
+			sip->owner->name,
+			(long) (t - sip->lastrtprx));
+		/* Issue a softhangup */
+		ast_softhangup_nolock(sip->owner, AST_SOFTHANGUP_DEV);
+	} else
+		ast_log(LOG_NOTICE,
+			"'%s' will not be disconnected in %ld seconds because it is directly bridged to another RTP stream\n",
+			sip->owner->name, (long) (t - sip->lastrtprx));
+	ast_channel_unlock(sip->owner);
+	/* forget the timeouts for this call, since a hangup
+	   has already been requested and we don't want to
+	   repeatedly request hangups
+	*/
+	sip->rtptimeout = 0;
+	sip->rtpholdtimeout = 0;
 }
 
 /*! \brief The SIP monitoring thread 



More information about the asterisk-commits mailing list