[asterisk-commits] branch murf/bug_6072 r8663 - in /team/murf/bug_6072: ./ apps/ channels/ utils/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Jan 25 10:55:34 MST 2006


Author: murf
Date: Wed Jan 25 11:55:26 2006
New Revision: 8663

URL: http://svn.digium.com/view/asterisk?rev=8663&view=rev
Log:
Merged revisions 8232,8242,8276,8281,8320,8347,8394,8412,8414,8418 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r8232 | russell | 2006-01-18 21:17:45 -0700 (Wed, 18 Jan 2006) | 3 lines

fix a seg fault due to assuming that space gets allocatted on the stack in the
same order that we declare the variables (issue #6290)

........
r8242 | russell | 2006-01-18 21:56:48 -0700 (Wed, 18 Jan 2006) | 3 lines

fix Message-Account header to use the ip address if the fromdomain 
isn't set (issue #6278)

........
r8276 | tilghman | 2006-01-19 12:14:37 -0700 (Thu, 19 Jan 2006) | 2 lines

Bug 6072 - Memory leaks in the expression parser

........
r8281 | oej | 2006-01-19 12:40:28 -0700 (Thu, 19 Jan 2006) | 2 lines

Enable "musicclass" setting for sip peers as per the config sample.

........
r8320 | mogorman | 2006-01-19 18:00:46 -0700 (Thu, 19 Jan 2006) | 3 lines

solved problem with delayreject and iax trunking
bug 4291

........
r8347 | russell | 2006-01-20 11:34:42 -0700 (Fri, 20 Jan 2006) | 2 lines

fix invalid value of prev_q (issue #6302)

........
r8394 | tilghman | 2006-01-21 11:29:39 -0700 (Sat, 21 Jan 2006) | 2 lines

Bug 5936 - AddQueueMember fails on realtime queue, if queue not yet loaded

........
r8412 | russell | 2006-01-21 16:17:06 -0700 (Sat, 21 Jan 2006) | 2 lines

prevent the possibility of writing outside of the available workspace (issue #6271)

........
r8414 | russell | 2006-01-21 16:43:14 -0700 (Sat, 21 Jan 2006) | 2 lines

temporarily revert substring fix pending the result of the discussion in issue #6271

........
r8418 | russell | 2006-01-21 19:05:41 -0700 (Sat, 21 Jan 2006) | 3 lines

add a modified fix to prevent writing outside of the provided workspace when 
calculating a substring (issue #6271)

........

Modified:
    team/murf/bug_6072/   (props changed)
    team/murf/bug_6072/apps/app_dial.c
    team/murf/bug_6072/apps/app_queue.c
    team/murf/bug_6072/asterisk.c
    team/murf/bug_6072/channel.c
    team/murf/bug_6072/channels/chan_sip.c
    team/murf/bug_6072/channels/chan_zap.c
    team/murf/bug_6072/utils/astman.c

Propchange: team/murf/bug_6072/
------------------------------------------------------------------------------
    automerge = 1

Propchange: team/murf/bug_6072/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Jan 25 11:55:26 2006
@@ -1,1 +1,1 @@
-/branches/1.2:1-8422
+/branches/1.2:1-8662

Modified: team/murf/bug_6072/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug_6072/apps/app_dial.c?rev=8663&r1=8662&r2=8663&view=diff
==============================================================================
--- team/murf/bug_6072/apps/app_dial.c (original)
+++ team/murf/bug_6072/apps/app_dial.c Wed Jan 25 11:55:26 2006
@@ -648,6 +648,7 @@
 					ast_hangup(o->chan);
 					o->chan = NULL;
 					ast_clear_flag(o, DIAL_STILLGOING);
+					HANDLE_CAUSE(in->hangupcause, in);
 				}
 			}
 			o = o->next;

Modified: team/murf/bug_6072/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug_6072/apps/app_queue.c?rev=8663&r1=8662&r2=8663&view=diff
==============================================================================
--- team/murf/bug_6072/apps/app_queue.c (original)
+++ team/murf/bug_6072/apps/app_queue.c Wed Jan 25 11:55:26 2006
@@ -755,6 +755,48 @@
 	}
 }
 
+static void free_members(struct ast_call_queue *q, int all)
+{
+	/* Free non-dynamic members */
+	struct member *curm, *next, *prev = NULL;
+
+	for (curm = q->members; curm; curm = next) {
+		next = curm->next;
+		if (all || !curm->dynamic) {
+			if (prev)
+				prev->next = next;
+			else
+				q->members = next;
+			free(curm);
+		} else 
+			prev = curm;
+	}
+}
+
+static void destroy_queue(struct ast_call_queue *q)
+{
+	free_members(q, 1);
+	ast_mutex_destroy(&q->lock);
+	free(q);
+}
+
+static void remove_queue(struct ast_call_queue *q)
+{
+	struct ast_call_queue *cur, *prev = NULL;
+
+	ast_mutex_lock(&qlock);
+	for (cur = queues; cur; cur = cur->next) {
+		if (cur == q) {
+			if (prev)
+				prev->next = cur->next;
+			else
+				queues = cur->next;
+		} else {
+			prev = cur;
+		}
+	}
+	ast_mutex_unlock(&qlock);
+}
 
 /*!\brief Reload a single queue via realtime.
    \return Return the queue, or NULL if it doesn't exist.
@@ -811,7 +853,7 @@
 					prev_q->next = q->next;
 				}
 				ast_mutex_unlock(&q->lock);
-				free(q);
+				destroy_queue(q);
 			} else
 				ast_mutex_unlock(&q->lock);
 		}
@@ -997,48 +1039,6 @@
 	return res;
 }
 
-static void free_members(struct ast_call_queue *q, int all)
-{
-	/* Free non-dynamic members */
-	struct member *curm, *next, *prev;
-
-	curm = q->members;
-	prev = NULL;
-	while(curm) {
-		next = curm->next;
-		if (all || !curm->dynamic) {
-			if (prev)
-				prev->next = next;
-			else
-				q->members = next;
-			free(curm);
-		} else 
-			prev = curm;
-		curm = next;
-	}
-}
-
-static void destroy_queue(struct ast_call_queue *q)
-{
-	struct ast_call_queue *cur, *prev = NULL;
-
-	ast_mutex_lock(&qlock);
-	for (cur = queues; cur; cur = cur->next) {
-		if (cur == q) {
-			if (prev)
-				prev->next = cur->next;
-			else
-				queues = cur->next;
-		} else {
-			prev = cur;
-		}
-	}
-	ast_mutex_unlock(&qlock);
-	free_members(q, 1);
-        ast_mutex_destroy(&q->lock);
-	free(q);
-}
-
 static int play_file(struct ast_channel *chan, char *filename)
 {
 	int res;
@@ -1246,6 +1246,7 @@
 	ast_mutex_unlock(&q->lock);
 	if (q->dead && !q->count) {	
 		/* It's dead and nobody is in it, so kill it */
+		remove_queue(q);
 		destroy_queue(q);
 	}
 }
@@ -3266,7 +3267,7 @@
 			else
 				queues = q->next;
 			if (!q->count) {
-				free(q);
+				destroy_queue(q);
 			} else
 				ast_log(LOG_WARNING, "XXX Leaking a little memory :( XXX\n");
 		} else {

Modified: team/murf/bug_6072/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug_6072/asterisk.c?rev=8663&r1=8662&r2=8663&view=diff
==============================================================================
--- team/murf/bug_6072/asterisk.c (original)
+++ team/murf/bug_6072/asterisk.c Wed Jan 25 11:55:26 2006
@@ -18,6 +18,7 @@
 
 
 /* Doxygenified Copyright Header */
+
 /*!
  * \mainpage Asterisk -- An Open Source Telephony Toolkit
  *

Modified: team/murf/bug_6072/channel.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug_6072/channel.c?rev=8663&r1=8662&r2=8663&view=diff
==============================================================================
--- team/murf/bug_6072/channel.c (original)
+++ team/murf/bug_6072/channel.c Wed Jan 25 11:55:26 2006
@@ -2005,10 +2005,12 @@
 {
 	int res = -1;
 
+	ast_mutex_lock(&chan->lock);
 	/* Stop if we're a zombie or need a soft hangup */
-	if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) 
+	if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
+		ast_mutex_unlock(&chan->lock);
 		return -1;
-	ast_mutex_lock(&chan->lock);
+	}
 	if (chan->tech->indicate)
 		res = chan->tech->indicate(chan, condition);
 	ast_mutex_unlock(&chan->lock);
@@ -3233,11 +3235,14 @@
 			res = AST_BRIDGE_RETRY;
 			break;
 		}
-		to = ast_tvdiff_ms(bridge_end, ast_tvnow());
-		if (to <= 0) {
-			res = AST_BRIDGE_RETRY;
-			break;
-		}
+		if (bridge_end.tv_sec) {
+			to = ast_tvdiff_ms(bridge_end, ast_tvnow());
+			if (to <= 0) {
+				res = AST_BRIDGE_RETRY;
+				break;
+			}
+		} else
+			to = -1;
 		who = ast_waitfor_n(cs, 2, &to);
 		if (!who) {
 			ast_log(LOG_DEBUG, "Nobody there, continuing...\n"); 
@@ -3830,7 +3835,7 @@
 		}
 
 		tocopy = (f->samples > samples) ? samples : f->samples;
-		bytestocopy = ast_codec_get_len(queue->format, samples);
+		bytestocopy = ast_codec_get_len(queue->format, tocopy);
 		memcpy(buf, f->data, bytestocopy);
 		samples -= tocopy;
 		buf += tocopy;

Modified: team/murf/bug_6072/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug_6072/channels/chan_sip.c?rev=8663&r1=8662&r2=8663&view=diff
==============================================================================
--- team/murf/bug_6072/channels/chan_sip.c (original)
+++ team/murf/bug_6072/channels/chan_sip.c Wed Jan 25 11:55:26 2006
@@ -560,6 +560,8 @@
 #define SIP_CALL_LIMIT		(1 << 29)
 /* Remote Party-ID Support */
 #define SIP_SENDRPID		(1 << 30)
+/* Did this connection increment the counter of in-use calls? */
+#define SIP_INC_COUNT (1 << 31)
 
 #define SIP_FLAGS_TO_COPY \
 	(SIP_PROMISCREDIR | SIP_TRUSTRPID | SIP_SENDRPID | SIP_DTMF | SIP_REINVITE | \
@@ -2224,7 +2226,8 @@
 		/* incoming and outgoing affects the inUse counter */
 		case DEC_CALL_LIMIT:
 			if ( *inuse > 0 ) {
-				(*inuse)--;
+			         if (ast_test_flag(fup,SIP_INC_COUNT))
+				         (*inuse)--;
 			} else {
 				*inuse = 0;
 			}
@@ -2244,6 +2247,7 @@
 				}
 			}
 			(*inuse)++;
+	                ast_set_flag(fup,SIP_INC_COUNT);
 			if (option_debug > 1 || sipdebug) {
 				ast_log(LOG_DEBUG, "Call %s %s '%s' is %d out of %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *inuse, *call_limit);
 			}
@@ -10615,7 +10619,8 @@
 			}
 		} else {
 			ast_log(LOG_WARNING, "Invalid transfer information from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr));
-			ast_queue_hangup(p->owner);
+			if (p->owner)
+				ast_queue_hangup(p->owner);
 		}
 	} else if (p->owner)
 		ast_queue_hangup(p->owner);
@@ -10940,8 +10945,10 @@
 		ast_log(LOG_DEBUG, "**** Received %s (%d) - Command in SIP %s\n", sip_methods[p->method].text, sip_methods[p->method].id, cmd); 
 
 	if (p->icseq && (p->icseq > seqno)) {
-		ast_log(LOG_DEBUG, "Ignoring too old SIP packet packet %d (expecting >= %d)\n", seqno, p->icseq);
-		transmit_response(p, "503 Server error", req);	/* We must respond according to RFC 3261 sec 12.2 */
+		if (option_debug)
+			ast_log(LOG_DEBUG, "Ignoring too old SIP packet packet %d (expecting >= %d)\n", seqno, p->icseq);
+		if (req->method != SIP_ACK)
+			transmit_response(p, "503 Server error", req);	/* We must respond according to RFC 3261 sec 12.2 */
 		return -1;
 	} else if (p->icseq && (p->icseq == seqno) && req->method != SIP_ACK &&(p->method != SIP_CANCEL|| ast_test_flag(p, SIP_ALREADYGONE))) {
 		/* ignore means "don't do anything with it" but still have to 
@@ -12796,14 +12803,11 @@
 /*! \brief  sip_addheader: Add a SIP header ---*/
 static int sip_addheader(struct ast_channel *chan, void *data)
 {
-	int arglen;
 	int no = 0;
 	int ok = 0;
-	char *content = (char *) NULL;
 	char varbuf[128];
 	
-	arglen = strlen(data);
-	if (!arglen) {
+	if (ast_strlen_zero((char *)data)) {
 		ast_log(LOG_WARNING, "This application requires the argument: Header\n");
 		return 0;
 	}
@@ -12812,14 +12816,12 @@
 	/* Check for headers */
 	while (!ok && no <= 50) {
 		no++;
-		snprintf(varbuf, sizeof(varbuf), "_SIPADDHEADER%.2d", no);
-		content = pbx_builtin_getvar_helper(chan, varbuf);
-
-		if (!content)
+		snprintf(varbuf, sizeof(varbuf), "_SIPADDHEADER%02d", no);
+		if (ast_strlen_zero(pbx_builtin_getvar_helper(chan, varbuf + 1)))
 			ok = 1;
 	}
 	if (ok) {
-		pbx_builtin_setvar_helper (chan, varbuf, data);
+		pbx_builtin_setvar_helper (chan, varbuf, (char *)data);
 		if (sipdebug)
 			ast_log(LOG_DEBUG,"SIP Header added \"%s\" as %s\n", (char *) data, varbuf);
 	} else {

Modified: team/murf/bug_6072/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug_6072/channels/chan_zap.c?rev=8663&r1=8662&r2=8663&view=diff
==============================================================================
--- team/murf/bug_6072/channels/chan_zap.c (original)
+++ team/murf/bug_6072/channels/chan_zap.c Wed Jan 25 11:55:26 2006
@@ -4200,6 +4200,10 @@
                                      (ast->_state == AST_STATE_RINGING))) {
                                         ast_log(LOG_DEBUG, "Answering on polarity switch!\n");
                                         ast_setstate(p->owner, AST_STATE_UP);
+					if(p->hanguponpolarityswitch) {
+						gettimeofday(&p->polaritydelaytv, NULL);
+					}
+					break;
                                 } else
                                         ast_log(LOG_DEBUG, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state);
 			} 

Modified: team/murf/bug_6072/utils/astman.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug_6072/utils/astman.c?rev=8663&r1=8662&r2=8663&view=diff
==============================================================================
--- team/murf/bug_6072/utils/astman.c (original)
+++ team/murf/bug_6072/utils/astman.c Wed Jan 25 11:55:26 2006
@@ -111,6 +111,7 @@
 				prev->next = chan->next;
 			else
 				chans = chan->next;
+			free(chan);
 			return;
 		}
 		prev = chan;



More information about the asterisk-commits mailing list