[asterisk-commits] branch bweschke/gain_functions r16848 - in /team/bweschke/gain_functions: ./ ...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Mar 31 19:33:29 MST 2006


Author: bweschke
Date: Fri Mar 31 20:33:27 2006
New Revision: 16848

URL: http://svn.digium.com/view/asterisk?rev=16848&view=rev
Log:
Merged revisions 16743,16745,16759,16772,16774-16775,16804,16825,16829 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r16743 | kpfleming | 2006-03-31 12:28:52 -0600 (Fri, 31 Mar 2006) | 10 lines

Merged revisions 16742 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r16742 | kpfleming | 2006-03-31 12:24:22 -0600 (Fri, 31 Mar 2006) | 2 lines

ensure that hint watchers (subscribers) cannot be added or removed while the dialplan is being modified

........

................
r16745 | russell | 2006-03-31 12:43:45 -0600 (Fri, 31 Mar 2006) | 10 lines

Merged revisions 16744 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r16744 | russell | 2006-03-31 13:42:09 -0500 (Fri, 31 Mar 2006) | 2 lines

fix the situation where bindport is specified but bindaddr is not (issue #6616)

........

................
r16759 | russell | 2006-03-31 13:02:27 -0600 (Fri, 31 Mar 2006) | 5 lines

- code formatting tweaks
- use the callno stored in a local variable
- store the result of atoi() so it's only called once
(issue #6833)

................
r16772 | russell | 2006-03-31 13:14:28 -0600 (Fri, 31 Mar 2006) | 2 lines

move a NULL check to before the first time the pointer is dereferenced (issue #6832)

................
r16774 | oej | 2006-03-31 13:40:27 -0600 (Fri, 31 Mar 2006) | 3 lines

- Reference to doc/security.txt instead of SECURITY
- Instruct people to READ THE DOCUMENTATION!!!

................
r16775 | oej | 2006-03-31 13:41:35 -0600 (Fri, 31 Mar 2006) | 2 lines

Typo

................
r16804 | bweschke | 2006-03-31 15:02:23 -0600 (Fri, 31 Mar 2006) | 3 lines

 Don't process re-subscribes as new subscriptions.  


................
r16825 | oej | 2006-03-31 18:24:05 -0600 (Fri, 31 Mar 2006) | 3 lines

Reverse revision 16804 that disables authentication
and a lot of other issues...

................
r16829 | oej | 2006-03-31 18:44:36 -0600 (Fri, 31 Mar 2006) | 2 lines

Don't add ast_extension_state on re-subscribes

................

Modified:
    team/bweschke/gain_functions/   (props changed)
    team/bweschke/gain_functions/README
    team/bweschke/gain_functions/channels/chan_iax2.c
    team/bweschke/gain_functions/channels/chan_sip.c
    team/bweschke/gain_functions/pbx.c

Propchange: team/bweschke/gain_functions/
------------------------------------------------------------------------------
Binary property 'branch-1.2-blocked' - no diff available.

Propchange: team/bweschke/gain_functions/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/bweschke/gain_functions/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Mar 31 20:33:27 2006
@@ -1,1 +1,1 @@
-/trunk:1-16727
+/trunk:1-16847

Modified: team/bweschke/gain_functions/README
URL: http://svn.digium.com/view/asterisk/team/bweschke/gain_functions/README?rev=16848&r1=16847&r2=16848&view=diff
==============================================================================
--- team/bweschke/gain_functions/README (original)
+++ team/bweschke/gain_functions/README Fri Mar 31 20:33:27 2006
@@ -2,14 +2,14 @@
 by Mark Spencer <markster at digium.com>
 and the Asterisk.org developer community
 
-Copyright (C) 2001-2005 Digium, Inc.
+Copyright (C) 2001-2006 Digium, Inc.
 and other copyright holders.
 ================================================================
 
 * SECURITY
   It is imperative that you read and fully understand the contents of
-the SECURITY file before you attempt to configure and run an Asterisk
-server.
+the security information file (doc/security.txt) before you attempt 
+to configure and run an Asterisk server.
 
 * WHAT IS ASTERISK ?
   Asterisk is an Open Source PBX and telephony toolkit.  It is, in a
@@ -84,11 +84,18 @@
 
   So let's proceed:
 
-1) Run "make"
+1) Read the README files.
+   There are more README files than this one in the doc/ directory.
+   Start with doc/00README.1st
+   You may also want to check the configuration files that contain
+   examples and reference guides. They are all in the configs/
+   directory.
+
+2) Run "make"
 
   Assuming the build completes successfully:
 
-2) Run "make install"
+3) Run "make install"
 
   Each time you update or checkout from the repository, you are strongly
 encouraged to ensure all previous object files are removed to avoid internal 
@@ -99,7 +106,7 @@
   If this is your first time working with Asterisk, you may wish to install
 the sample PBX, with demonstration extensions, etc.  If so, run:
 
-3) "make samples"
+4) "make samples"
 
   Doing so will overwrite any existing config files you have.
 

Modified: team/bweschke/gain_functions/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/gain_functions/channels/chan_iax2.c?rev=16848&r1=16847&r2=16848&view=diff
==============================================================================
--- team/bweschke/gain_functions/channels/chan_iax2.c (original)
+++ team/bweschke/gain_functions/channels/chan_iax2.c Fri Mar 31 20:33:27 2006
@@ -1611,6 +1611,8 @@
 	int callno = f->callno;
 	
 	/* Called with iaxsl held */
+	if (!iaxs[callno])
+		return -1;
 	if (option_debug > 2 && iaxdebug)
 		ast_log(LOG_DEBUG, "Sending %d on %d/%d to %s:%d\n", f->ts, callno, iaxs[callno]->peercallno, ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[callno]->addr.sin_addr), ntohs(iaxs[callno]->addr.sin_port));
 	/* Don't send if there was an error, but return error instead */
@@ -1618,8 +1620,6 @@
 		ast_log(LOG_WARNING, "Call number = %d\n", callno);
 		return -1;
 	}
-	if (!iaxs[callno])
-		return -1;
 	if (iaxs[callno]->error)
 		return -1;
 	if (f->transfer) {
@@ -1713,11 +1713,9 @@
 	ast_mutex_lock(&iaxsl[callno]);
 	pvt = iaxs[callno];
 	gettimeofday(&lastused[callno], NULL);
-
-	if (pvt)
-		owner = pvt->owner;
-	else
-		owner = NULL;
+	
+	owner = pvt ? pvt->owner : NULL;
+
 	if (owner) {
 		if (ast_mutex_trylock(&owner->lock)) {
 			ast_log(LOG_NOTICE, "Avoiding IAX destroy deadlock\n");
@@ -1770,9 +1768,8 @@
 			if (cur->callno == pvt->callno) 
 				cur->retries = -1;
 		}
-		if (pvt->reg) {
+		if (pvt->reg)
 			pvt->reg->callno = 0;
-		}
 		if (!owner) {
 			if (pvt->vars) {
 				ast_variables_destroy(pvt->vars);
@@ -1828,37 +1825,37 @@
 	/* Make sure this call is still active */
 	if (callno) 
 		ast_mutex_lock(&iaxsl[callno]);
-	if ((f->callno) && iaxs[f->callno]) {
+	if (callno && iaxs[callno]) {
 		if ((f->retries < 0) /* Already ACK'd */ ||
 		    (f->retries >= max_retries) /* Too many attempts */) {
 				/* Record an error if we've transmitted too many times */
 				if (f->retries >= max_retries) {
 					if (f->transfer) {
 						/* Transfer timeout */
-						send_command(iaxs[f->callno], AST_FRAME_IAX, IAX_COMMAND_TXREJ, 0, NULL, 0, -1);
+						send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_TXREJ, 0, NULL, 0, -1);
 					} else if (f->final) {
 						if (f->final) 
-							iax2_destroy_nolock(f->callno);
+							iax2_destroy_nolock(callno);
 					} else {
-						if (iaxs[f->callno]->owner)
+						if (iaxs[callno]->owner)
 							ast_log(LOG_WARNING, "Max retries exceeded to host %s on %s (type = %d, subclass = %d, ts=%d, seqno=%d)\n", ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[f->callno]->addr.sin_addr),iaxs[f->callno]->owner->name , f->af.frametype, f->af.subclass, f->ts, f->oseqno);
-						iaxs[f->callno]->error = ETIMEDOUT;
-						if (iaxs[f->callno]->owner) {
+						iaxs[callno]->error = ETIMEDOUT;
+						if (iaxs[callno]->owner) {
 							struct ast_frame fr = { 0, };
 							/* Hangup the fd */
 							fr.frametype = AST_FRAME_CONTROL;
 							fr.subclass = AST_CONTROL_HANGUP;
-							iax2_queue_frame(f->callno, &fr);
+							iax2_queue_frame(callno, &fr);
 							/* Remember, owner could disappear */
-							if (iaxs[f->callno]->owner)
-								iaxs[f->callno]->owner->hangupcause = AST_CAUSE_DESTINATION_OUT_OF_ORDER;
+							if (iaxs[callno]->owner)
+								iaxs[callno]->owner->hangupcause = AST_CAUSE_DESTINATION_OUT_OF_ORDER;
 						} else {
-							if (iaxs[f->callno]->reg) {
-								memset(&iaxs[f->callno]->reg->us, 0, sizeof(iaxs[f->callno]->reg->us));
-								iaxs[f->callno]->reg->regstate = REG_STATE_TIMEOUT;
-								iaxs[f->callno]->reg->refresh = IAX_DEFAULT_REG_EXPIRE;
+							if (iaxs[callno]->reg) {
+								memset(&iaxs[callno]->reg->us, 0, sizeof(iaxs[callno]->reg->us));
+								iaxs[callno]->reg->regstate = REG_STATE_TIMEOUT;
+								iaxs[callno]->reg->refresh = IAX_DEFAULT_REG_EXPIRE;
 							}
-							iax2_destroy_nolock(f->callno);
+							iax2_destroy_nolock(callno);
 						}
 					}
 
@@ -1929,15 +1926,16 @@
 			max_jitter_buffer = 0;
 	} else {
 		if (argc == 5) {
-			if ((atoi(argv[3]) >= 0) && (atoi(argv[3]) < IAX_MAX_CALLS)) {
-				if (iaxs[atoi(argv[3])]) {
-					iaxs[atoi(argv[3])]->jitterbuffer = atoi(argv[4]);
-					if (iaxs[atoi(argv[3])]->jitterbuffer < 0)
-						iaxs[atoi(argv[3])]->jitterbuffer = 0;
+			int callno = atoi(argv[3]);
+			if ((callno >= 0) && (callno < IAX_MAX_CALLS)) {
+				if (iaxs[callno]) {
+					iaxs[callno]->jitterbuffer = atoi(argv[4]);
+					if (iaxs[callno]->jitterbuffer < 0)
+						iaxs[callno]->jitterbuffer = 0;
 				} else
-					ast_cli(fd, "No such call '%d'\n", atoi(argv[3]));
+					ast_cli(fd, "No such call '%d'\n", callno);
 			} else
-				ast_cli(fd, "%d is not a valid call number\n", atoi(argv[3]));
+				ast_cli(fd, "%d is not a valid call number\n", callno);
 		}
 	}
 	return RESULT_SUCCESS;
@@ -9208,6 +9206,18 @@
 		/*	ast_log(LOG_WARNING, "Ignoring %s\n", v->name); */
 		v = v->next;
 	}
+	
+	if (defaultsockfd < 0) {
+		if (!(ns = ast_netsock_bind(netsock, io, "0.0.0.0", portno, tos, socket_read, NULL))) {
+			ast_log(LOG_ERROR, "Unable to create network socket: %s\n", strerror(errno));
+		} else {
+			if (option_verbose > 1)
+				ast_verbose(VERBOSE_PREFIX_2 "Binding IAX2 to default address 0.0.0.0:%d\n", portno);
+			defaultsockfd = ast_netsock_sockfd(ns);
+			ast_netsock_unref(ns);
+		}
+	}
+	
 	if (min_reg_expire > max_reg_expire) {
 		ast_log(LOG_WARNING, "Minimum registration interval of %d is more than maximum of %d, resetting minimum to %d\n",
 			min_reg_expire, max_reg_expire, max_reg_expire);
@@ -9988,9 +9998,6 @@
 	struct iax2_registry *reg;
 	struct iax2_peer *peer;
 	
-	struct ast_netsock *ns;
-	struct sockaddr_in sin;
-	
 	ast_custom_function_register(&iaxpeer_function);
 
 	iax_set_output(iax_debug_output);
@@ -9999,10 +10006,6 @@
 	jb_setoutput(jb_error_output, jb_warning_output, NULL);
 #endif
 	
-	sin.sin_family = AF_INET;
-	sin.sin_port = htons(IAX_DEFAULT_PORTNO);
-	sin.sin_addr.s_addr = INADDR_ANY;
-
 #ifdef IAX_TRUNKING
 #ifdef ZT_TIMERACK
 	timingfd = open("/dev/zap/timer", O_RDWR);
@@ -10055,19 +10058,7 @@
 
 	if (ast_register_switch(&iax2_switch)) 
 		ast_log(LOG_ERROR, "Unable to register IAX switch\n");
-	
-	if (defaultsockfd < 0) {
-		if (!(ns = ast_netsock_bindaddr(netsock, io, &sin, tos, socket_read, NULL))) {
-			ast_log(LOG_ERROR, "Unable to create network socket: %s\n", strerror(errno));
-			return -1;
-		} else {
-			if (option_verbose > 1)
-				ast_verbose(VERBOSE_PREFIX_2 "Binding IAX2 to default address 0.0.0.0:%d\n", IAX_DEFAULT_PORTNO);
-			defaultsockfd = ast_netsock_sockfd(ns);
-			ast_netsock_unref(ns);
-		}
-	}
-	
+
 	res = start_network_thread();
 	if (!res) {
 		if (option_verbose > 1) 

Modified: team/bweschke/gain_functions/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/gain_functions/channels/chan_sip.c?rev=16848&r1=16847&r2=16848&view=diff
==============================================================================
--- team/bweschke/gain_functions/channels/chan_sip.c (original)
+++ team/bweschke/gain_functions/channels/chan_sip.c Fri Mar 31 20:33:27 2006
@@ -10985,6 +10985,7 @@
 	char *event = get_header(req, "Event");	/* Get Event package name */
 	char *accept = get_header(req, "Accept");
 	char *eventparam;
+	int resubscribe = (p->subscribed != NONE);
 
 	if (p->initreq.headers) {	
 		/* We already have a dialog */
@@ -10996,7 +10997,7 @@
 			ast_log(LOG_DEBUG, "Got a subscription within the context of another call, can't handle that - %s (Method %s)\n", p->callid, sip_methods[p->initreq.method].text);
 			return 0;
 		} else if (debug) {
-			if (p->subscribed != NONE)
+			if (resubscribe)
 				ast_log(LOG_DEBUG, "Got a re-subscribe on existing subscription %s\n", p->callid);
 			else
 				ast_log(LOG_DEBUG, "Got a new subscription %s (possibly with auth)\n", p->callid);
@@ -11109,7 +11110,7 @@
  			ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);	
 			return 0;
 		}
-		if (p->subscribed != MWI_NOTIFICATION)
+		if (p->subscribed != MWI_NOTIFICATION && !resubscribe)
 			p->stateid = ast_extension_state_add(p->context, p->exten, cb_extensionstate, p);
 	}
 

Modified: team/bweschke/gain_functions/pbx.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/gain_functions/pbx.c?rev=16848&r1=16847&r2=16848&view=diff
==============================================================================
--- team/bweschke/gain_functions/pbx.c (original)
+++ team/bweschke/gain_functions/pbx.c Fri Mar 31 20:33:27 2006
@@ -470,6 +470,12 @@
 AST_MUTEX_DEFINE_STATIC(switchlock);		/*!< Lock for switches */
 
 static int stateid = 1;
+/* WARNING:
+   When holding this list's lock, do _not_ do anything that will cause conlock
+   to be taken, unless you _already_ hold it. The ast_merge_contexts_and_delete
+   function will take the locks in conlock/hints order, so any other
+   paths that require both locks must also take them in that order.
+*/
 static AST_LIST_HEAD_STATIC(hints, ast_hint);
 struct ast_state_cb *statecbs = NULL;
 
@@ -3508,9 +3514,20 @@
 	int length;
 	struct ast_state_cb *thiscb, *prevcb;
 
+	AST_LIST_HEAD_INIT(&store);
+
+	/* it is very important that this function hold the hint list lock _and_ the conlock
+	   during its operation; not only do we need to ensure that the list of contexts
+	   and extensions does not change, but also that no hint callbacks (watchers) are
+	   added or removed during the merge/delete process
+
+	   in addition, the locks _must_ be taken in this order, because there are already
+	   other code paths that use this order
+	*/
+	ast_mutex_lock(&conlock);
+	AST_LIST_LOCK(&hints);
+
 	/* preserve all watchers for hints associated with this registrar */
-	AST_LIST_HEAD_INIT(&store);
-	AST_LIST_LOCK(&hints);
 	AST_LIST_TRAVERSE(&hints, hint, list) {
 		if (hint->callbacks && !strcmp(registrar, hint->exten->parent->registrar)) {
 			length = strlen(hint->exten->exten) + strlen(hint->exten->parent->name) + 2 + sizeof(*this);
@@ -3526,10 +3543,8 @@
 			AST_LIST_INSERT_HEAD(&store, this, list);
 		}
 	}
-	AST_LIST_UNLOCK(&hints);
 
 	tmp = *extcontexts;
-	ast_mutex_lock(&conlock);
 	if (registrar) {
 		__ast_context_destroy(NULL,registrar);
 		while (tmp) {
@@ -3549,7 +3564,6 @@
 		*extcontexts = NULL;
 	} else 
 		ast_log(LOG_WARNING, "Requested contexts didn't get merged\n");
-	ast_mutex_unlock(&conlock);
 
 	/* restore the watchers for hints that can be found; notify those that
 	   cannot be restored
@@ -3557,7 +3571,6 @@
 	while ((this = AST_LIST_REMOVE_HEAD(&store, list))) {
 		exten = ast_hint_extension(NULL, this->context, this->exten);
 		/* Find the hint in the list of hints */
-		AST_LIST_LOCK(&hints);
 		AST_LIST_TRAVERSE(&hints, hint, list) {
 			if (hint->exten == exten)
 				break;
@@ -3580,9 +3593,11 @@
 			hint->callbacks = this->callbacks;
 			hint->laststate = this->laststate;
 		}
-		AST_LIST_UNLOCK(&hints);
 		free(this);
 	}
+
+	AST_LIST_UNLOCK(&hints);
+	ast_mutex_unlock(&conlock);
 
 	return;	
 }



More information about the asterisk-commits mailing list