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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 18 01:13:46 CDT 2007


Author: rizzo
Date: Wed Jul 18 01:13:45 2007
New Revision: 75525

URL: http://svn.digium.com/view/asterisk?view=rev&rev=75525
Log:
correct one misuse of 'flags' in sip_pkt:

because we only need two status bits there, use two distinct
variables and get rid of the mixture of ast_*flags
operation and explicit manipulation.
This improves readability, saves CPU time, and has no impact
in terms of memory now that ast_flags are 64 bit.

trunk candidate.



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=75525&r1=75524&r2=75525
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Wed Jul 18 01:13:45 2007
@@ -656,7 +656,7 @@
 	int headers;            /*!< # of SIP Headers */
 	int method;             /*!< Method of this request */
 	int lines;              /*!< Body Content */
-	uint64_t flags;		/*!< SIP_PKT Flags for this packet */
+	uint64_t flags;		/*!< SIP_PKT Flags for this packet */ /* XXX should be ast_flags */
 	unsigned int sdp_start; /*!< the line number where the SDP begins */
 	unsigned int sdp_end;   /*!< the line number where the SDP ends */
 	char *header[SIP_MAX_HEADERS];
@@ -1132,7 +1132,7 @@
 	return ast_test_flag(&pvt->flags[0], SIP_NEEDDESTROY) ? 1 : 0;
 }
 
-#define FLAG_RESPONSE (1 << 0)
+#define FLAG_RESPONSE (1 << 0)	/* basically, any non-zero value */
 #define FLAG_FATAL (1 << 1)
 
 /*! \brief sip packet - raw format for outbound packets that are sent or scheduled for transmission
@@ -1146,7 +1146,8 @@
 	int retrans;				/*!< Retransmission number */
 	int method;				/*!< SIP method for this packet */
 	int seqno;				/*!< Sequence number */
-	uint64_t flags;				/*!< non-zero if this is a response packet (e.g. 200 OK) */
+	int is_resp;				/*!< non-zero if this is a response packet (e.g. 200 OK) */
+	int is_fatal;				/*!< non-zero if this is a fatal error */
 	struct sip_pvt *pvt;			/*!< Owner AST call */
 	int retransid;				/*!< Retransmission ID */
 	int timer_a;				/*!< SIP timer A, retransmission timer */
@@ -2319,20 +2320,20 @@
 
 	/* Too many retries */
 	if (pkt->method != SIP_OPTIONS) {
-		if (ast_test_flag(pkt, FLAG_FATAL) || sipdebug)	/* Tell us if it's critical or if we're debugging */
+		if (pkt->is_fatal || sipdebug)	/* Tell us if it's critical or if we're debugging */
 			ast_log(LOG_WARNING, "Maximum retries exceeded on transmission %s for seqno %d (%s %s)\n",
 				pvt->callid, pkt->seqno,
-				ast_test_flag(pkt, FLAG_FATAL) ? "Critical" : "Non-critical",
-				ast_test_flag(pkt, FLAG_RESPONSE) ? "Response" : "Request");
+				pkt->is_fatal ? "Critical" : "Non-critical",
+				pkt->is_resp ? "Response" : "Request");
 	} else {
 		if ((pkt->method == SIP_OPTIONS) && sipdebug)
 			ast_log(LOG_WARNING, "Cancelling retransmit of OPTIONs (call id %s) \n", pvt->callid);
 	}
-	append_history(pvt, "MaxRetries", "%s", (ast_test_flag(pkt, FLAG_FATAL)) ? "(Critical)" : "(Non-critical)");
+	append_history(pvt, "MaxRetries", "%s", pkt->is_fatal ? "(Critical)" : "(Non-critical)");
  		
 	pkt->retransid = -1;
 
-	if (ast_test_flag(pkt, FLAG_FATAL)) {
+	if (pkt->is_fatal) {
 		/* the next call is unsafe, because we are called without dialoglock held,
 		 * and pvt could disappear while we unlock it
 		 */
@@ -2381,10 +2382,9 @@
 	pkt->method = sipmethod;
 	pkt->pvt = pvt_ref(p);
 	pkt->seqno = seqno;
-	if (resp)
-		ast_set_flag(pkt, FLAG_RESPONSE);
+	pkt->is_resp = resp;	/* mark as response */
 	if (mode == XMIT_CRITICAL)
-		ast_set_flag(pkt, FLAG_FATAL);
+		pkt->is_fatal = 1;
 	else if (mode != XMIT_RELIABLE)
 		ast_log(LOG_WARNING, "bad mode %d in __sip_reliable_xmit\n", mode);
 	pkt->timer_t1 = p->timer_t1;	/* Set SIP timer T1 */
@@ -2497,9 +2497,9 @@
   		p->outboundproxy = NULL;
 
 	for (cur = p->packets; cur; prev = cur, cur = cur->next) {
-		if (cur->seqno != seqno || ast_test_flag(cur, FLAG_RESPONSE) != resp)
+		if (cur->seqno != seqno || cur->is_resp != resp)
 			continue;
-		if (ast_test_flag(cur, FLAG_RESPONSE) || cur->method == sipmethod) {
+		if (cur->is_resp || cur->method == sipmethod) {
 			msg = "Found";
 			if (!resp && (seqno == p->pendinginvite)) {
 				if (option_debug)
@@ -2538,7 +2538,7 @@
 		}
 		cur = p->packets;
 		method = (cur->method) ? cur->method : find_sip_method(cur->data);
-		__sip_ack(p, cur->seqno, ast_test_flag(cur, FLAG_RESPONSE), method);
+		__sip_ack(p, cur->seqno, cur->is_resp, method);
 	}
 }
 
@@ -2552,9 +2552,9 @@
 	int res = -1;
 
 	for (cur = p->packets; cur; cur = cur->next) {
-		if (cur->seqno != seqno || ast_test_flag(cur, FLAG_RESPONSE) != resp)
+		if (cur->seqno != seqno || cur->is_resp != resp)
 			continue;
-		if (ast_test_flag(cur, FLAG_RESPONSE) || cur->method == sipmethod) {
+		if (cur->is_resp || cur->method == sipmethod) {
 			/* this is our baby */
 			if (cur->retransid > -1) {
 				if (option_debug > 3 && sipdebug)




More information about the asterisk-commits mailing list