[asterisk-commits] kharwell: branch kharwell/pimp_sip_video r383921 - in /team/kharwell/pimp_sip...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Mar 26 14:28:51 CDT 2013


Author: kharwell
Date: Tue Mar 26 14:28:45 2013
New Revision: 383921

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383921
Log:
merged changes from pimp_my_sip branch

Modified:
    team/kharwell/pimp_sip_video/   (props changed)
    team/kharwell/pimp_sip_video/apps/app_meetme.c
    team/kharwell/pimp_sip_video/channels/chan_sip.c
    team/kharwell/pimp_sip_video/channels/chan_skinny.c
    team/kharwell/pimp_sip_video/channels/sig_pri.c
    team/kharwell/pimp_sip_video/contrib/scripts/install_prereq
    team/kharwell/pimp_sip_video/main/cdr.c
    team/kharwell/pimp_sip_video/main/manager_channels.c
    team/kharwell/pimp_sip_video/main/stasis.c
    team/kharwell/pimp_sip_video/res/res_sip/sip_distributor.c

Propchange: team/kharwell/pimp_sip_video/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Propchange: team/kharwell/pimp_sip_video/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 26 14:28:45 2013
@@ -1,1 +1,1 @@
-/team/group/pimp_my_sip:383711-383743
+/team/group/pimp_my_sip:383711-383743,383745-383920

Propchange: team/kharwell/pimp_sip_video/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Mar 26 14:28:45 2013
@@ -1,1 +1,1 @@
-/trunk:1-383729
+/trunk:1-383881

Modified: team/kharwell/pimp_sip_video/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_video/apps/app_meetme.c?view=diff&rev=383921&r1=383920&r2=383921
==============================================================================
--- team/kharwell/pimp_sip_video/apps/app_meetme.c (original)
+++ team/kharwell/pimp_sip_video/apps/app_meetme.c Tue Mar 26 14:28:45 2013
@@ -5926,7 +5926,16 @@
 			ringing_trunk = sla_choose_ringing_trunk(ringing_station->station, &s_trunk_ref, 1);
 			ast_mutex_unlock(&sla.lock);
 			if (!ringing_trunk) {
+				/* This case happens in a bit of a race condition.  If two stations answer
+				 * the outbound call at the same time, the first one will get connected to
+				 * the trunk.  When the second one gets here, it will not see any trunks
+				 * ringing so we have no idea what to conect it to.  So, we just hang up
+				 * on it. */
 				ast_debug(1, "Found no ringing trunk for station '%s' to answer!\n", ringing_station->station->name);
+				ast_dial_join(ringing_station->station->dial);
+				ast_dial_destroy(ringing_station->station->dial);
+				ringing_station->station->dial = NULL;
+				ast_free(ringing_station);
 				break;
 			}
 			/* Track the channel that answered this trunk */

Modified: team/kharwell/pimp_sip_video/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_video/channels/chan_sip.c?view=diff&rev=383921&r1=383920&r2=383921
==============================================================================
--- team/kharwell/pimp_sip_video/channels/chan_sip.c (original)
+++ team/kharwell/pimp_sip_video/channels/chan_sip.c Tue Mar 26 14:28:45 2013
@@ -16131,7 +16131,9 @@
 		ast_verb(3, "Registered SIP '%s' at %s\n", peer->name,
 			ast_sockaddr_stringify(&peer->addr));
 	}
+	sip_pvt_unlock(pvt);
 	sip_poke_peer(peer, 0);
+	sip_pvt_lock(pvt);
 	register_peer_exten(peer, 1);
 
 	/* Save User agent */
@@ -17163,9 +17165,9 @@
 	}
 	if (!res) {
 		if (send_mwi) {
-			ao2_unlock(p);
+			sip_pvt_unlock(p);
 			sip_send_mwi_to_peer(peer, 0);
-			ao2_lock(p);
+			sip_pvt_lock(p);
 		} else {
 			update_peer_lastmsgssent(peer, -1, 0);
 		}
@@ -29611,6 +29613,9 @@
 \note	This is done with 60 seconds between each ping,
 	unless forced by cli or manager. If peer is unreachable,
 	we check every 10th second by default.
+\note Do *not* hold a pvt lock while calling this function.
+	This function calls sip_alloc, which can cause a deadlock
+	if another sip_pvt is held.
 */
 static int sip_poke_peer(struct sip_peer *peer, int force)
 {

Modified: team/kharwell/pimp_sip_video/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_video/channels/chan_skinny.c?view=diff&rev=383921&r1=383920&r2=383921
==============================================================================
--- team/kharwell/pimp_sip_video/channels/chan_skinny.c (original)
+++ team/kharwell/pimp_sip_video/channels/chan_skinny.c Tue Mar 26 14:28:45 2013
@@ -6254,12 +6254,14 @@
 	struct ast_channel *c;
 	int event;
 	int instance;
+#ifdef AST_DEVMODE
 	int callreference;
-	/*int res = 0;*/
+	/* This is only used in AST_DEVMODE, as an argument to SKINNY_DEBUG */
+	callreference = letohl(req->data.stimulus.callreference);
+#endif
 
 	event = letohl(req->data.stimulus.stimulus);
 	instance = letohl(req->data.stimulus.stimulusInstance);
-	callreference = letohl(req->data.stimulus.callreference);
 
 	/*  Note that this call should be using the passed in instance and callreference */
 	sub = find_subchannel_by_instance_reference(d, d->lastlineinstance, d->lastcallreference);

Modified: team/kharwell/pimp_sip_video/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_video/channels/sig_pri.c?view=diff&rev=383921&r1=383920&r2=383921
==============================================================================
--- team/kharwell/pimp_sip_video/channels/sig_pri.c (original)
+++ team/kharwell/pimp_sip_video/channels/sig_pri.c Tue Mar 26 14:28:45 2013
@@ -6410,6 +6410,10 @@
 
 							snprintf(calledtonstr, sizeof(calledtonstr), "%d", e->ring.calledplan);
 							pbx_builtin_setvar_helper(c, "CALLEDTON", calledtonstr);
+							ast_channel_lock(c);
+							ast_channel_dialed(c)->number.plan = e->ring.calledplan;
+							ast_channel_unlock(c);
+
 							if (e->ring.redirectingreason >= 0) {
 								/* This is now just a status variable.  Use REDIRECTING() dialplan function. */
 								pbx_builtin_setvar_helper(c, "PRIREDIRECTREASON", redirectingreason2str(e->ring.redirectingreason));
@@ -6548,6 +6552,9 @@
 
 							snprintf(calledtonstr, sizeof(calledtonstr), "%d", e->ring.calledplan);
 							pbx_builtin_setvar_helper(c, "CALLEDTON", calledtonstr);
+							ast_channel_lock(c);
+							ast_channel_dialed(c)->number.plan = e->ring.calledplan;
+							ast_channel_unlock(c);
 
 							sig_pri_handle_subcmds(pri, chanpos, e->e, e->ring.subcmds,
 								e->ring.call);

Modified: team/kharwell/pimp_sip_video/contrib/scripts/install_prereq
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_video/contrib/scripts/install_prereq?view=diff&rev=383921&r1=383920&r2=383921
==============================================================================
--- team/kharwell/pimp_sip_video/contrib/scripts/install_prereq (original)
+++ team/kharwell/pimp_sip_video/contrib/scripts/install_prereq Tue Mar 26 14:28:45 2013
@@ -80,20 +80,16 @@
 }
 
 handle_debian() {
-	# echo "# Distribution is Debian or compatible"
 	extra_packs=`check_installed_debs $PACKAGES_DEBIAN`
 	$testcmd aptitude install -y $extra_packs
 }
 
 handle_rh() {
-	# echo "# Distribution is RedHat-based or compatible"
 	extra_packs=`check_installed_rpms $PACKAGES_RH`
-        # FIXME: is there yum with RHEL 4?
 	$testcmd yum install -y $extra_packs
 }
 
 handle_obsd() {
-	# echo "# Distribution is OpenBSD or compatible"
 	extra_packs=`check_installed_pkgs $PACKAGES_OBSD`
 	$testcmd pkg_add $extra_packs
 }

Modified: team/kharwell/pimp_sip_video/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_video/main/cdr.c?view=diff&rev=383921&r1=383920&r2=383921
==============================================================================
--- team/kharwell/pimp_sip_video/main/cdr.c (original)
+++ team/kharwell/pimp_sip_video/main/cdr.c Tue Mar 26 14:28:45 2013
@@ -122,6 +122,8 @@
 
 static int batchsafeshutdown;
 static const int BATCH_SAFE_SHUTDOWN_DEFAULT = 1;
+
+AST_MUTEX_DEFINE_STATIC(cdr_sched_lock);
 
 AST_MUTEX_DEFINE_STATIC(cdr_batch_lock);
 
@@ -1360,17 +1362,24 @@
 {
 	ast_cdr_submit_batch(0);
 	/* manually reschedule from this point in time */
+	ast_mutex_lock(&cdr_sched_lock);
 	cdr_sched = ast_sched_add(sched, batchtime * 1000, submit_scheduled_batch, NULL);
+	ast_mutex_unlock(&cdr_sched_lock);
 	/* returning zero so the scheduler does not automatically reschedule */
 	return 0;
 }
 
+/*! Do not hold the batch lock while calling this function */
 static void submit_unscheduled_batch(void)
 {
+	/* Prevent two deletes from happening at the same time */
+	ast_mutex_lock(&cdr_sched_lock);
 	/* this is okay since we are not being called from within the scheduler */
 	AST_SCHED_DEL(sched, cdr_sched);
 	/* schedule the submission to occur ASAP (1 ms) */
 	cdr_sched = ast_sched_add(sched, 1, submit_scheduled_batch, NULL);
+	ast_mutex_unlock(&cdr_sched_lock);
+
 	/* signal the do_cdr thread to wakeup early and do some work (that lazy thread ;) */
 	ast_mutex_lock(&cdr_pending_lock);
 	ast_cond_signal(&cdr_pending_cond);
@@ -1381,6 +1390,7 @@
 {
 	struct ast_cdr_batch_item *newtail;
 	int curr;
+	int submit_batch = 0;
 
 	if (!cdr)
 		return;
@@ -1427,10 +1437,14 @@
 
 	/* if we have enough stuff to post, then do it */
 	if (curr >= (batchsize - 1)) {
+		submit_batch = 1;
+	}
+	ast_mutex_unlock(&cdr_batch_lock);
+
+	/* Don't call submit_unscheduled_batch with the cdr_batch_lock held */
+	if (submit_batch) {
 		submit_unscheduled_batch();
 	}
-
-	ast_mutex_unlock(&cdr_batch_lock);
 }
 
 static void *do_cdr(void *data)
@@ -1576,7 +1590,9 @@
 	}
 
 	/* don't run the next scheduled CDR posting while reloading */
+	ast_mutex_lock(&cdr_sched_lock);
 	AST_SCHED_DEL(sched, cdr_sched);
+	ast_mutex_unlock(&cdr_sched_lock);
 
 	for (v = ast_variable_browse(config, "general"); v; v = v->next) {
 		if (!strcasecmp(v->name, "enable")) {
@@ -1617,7 +1633,9 @@
 	if (enabled && !batchmode) {
 		ast_log(LOG_NOTICE, "CDR simple logging enabled.\n");
 	} else if (enabled && batchmode) {
+		ast_mutex_lock(&cdr_sched_lock);
 		cdr_sched = ast_sched_add(sched, batchtime * 1000, submit_scheduled_batch, NULL);
+		ast_mutex_unlock(&cdr_sched_lock);
 		ast_log(LOG_NOTICE, "CDR batch mode logging enabled, first of either size %d or time %d seconds.\n", batchsize, batchtime);
 	} else {
 		ast_log(LOG_NOTICE, "CDR logging disabled, data will be lost.\n");
@@ -1629,7 +1647,9 @@
 		ast_cond_init(&cdr_pending_cond, NULL);
 		if (ast_pthread_create_background(&cdr_thread, NULL, do_cdr, NULL) < 0) {
 			ast_log(LOG_ERROR, "Unable to start CDR thread.\n");
+			ast_mutex_lock(&cdr_sched_lock);
 			AST_SCHED_DEL(sched, cdr_sched);
+			ast_mutex_unlock(&cdr_sched_lock);
 		} else {
 			ast_cli_register(&cli_submit);
 			ast_register_atexit(ast_cdr_engine_term);

Modified: team/kharwell/pimp_sip_video/main/manager_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_video/main/manager_channels.c?view=diff&rev=383921&r1=383920&r2=383921
==============================================================================
--- team/kharwell/pimp_sip_video/main/manager_channels.c (original)
+++ team/kharwell/pimp_sip_video/main/manager_channels.c Tue Mar 26 14:28:45 2013
@@ -637,7 +637,7 @@
 					 NULL);
 
 	/* If somehow we failed to add any routes, just shut down the whole
-	 * things and fail it.
+	 * thing and fail it.
 	 */
 	if (ret) {
 		manager_channels_shutdown();

Modified: team/kharwell/pimp_sip_video/main/stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_video/main/stasis.c?view=diff&rev=383921&r1=383920&r2=383921
==============================================================================
--- team/kharwell/pimp_sip_video/main/stasis.c (original)
+++ team/kharwell/pimp_sip_video/main/stasis.c Tue Mar 26 14:28:45 2013
@@ -472,7 +472,7 @@
 
 static int topic_pool_entry_hash(const void *obj, const int flags)
 {
-	const char *topic_name= (flags & OBJ_KEY) ? obj : stasis_topic_name(((struct topic_pool_entry*) obj)->topic);
+	const char *topic_name = (flags & OBJ_KEY) ? obj : stasis_topic_name(((struct topic_pool_entry*) obj)->topic);
 	return ast_str_case_hash(topic_name);
 }
 

Modified: team/kharwell/pimp_sip_video/res/res_sip/sip_distributor.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_video/res/res_sip/sip_distributor.c?view=diff&rev=383921&r1=383920&r2=383921
==============================================================================
--- team/kharwell/pimp_sip_video/res/res_sip/sip_distributor.c (original)
+++ team/kharwell/pimp_sip_video/res/res_sip/sip_distributor.c Tue Mar 26 14:28:45 2013
@@ -132,10 +132,11 @@
 static pj_bool_t authenticate(pjsip_rx_data *rdata)
 {
 	RAII_VAR(struct ast_sip_endpoint *, endpoint, ast_pjsip_rdata_get_endpoint(rdata), ao2_cleanup);
+	int is_ack = rdata->msg_info.msg->line.req.method.id == PJSIP_ACK_METHOD;
 
 	ast_assert(endpoint != NULL);
 
-	if (ast_sip_requires_authentication(endpoint, rdata)) {
+	if (!is_ack && ast_sip_requires_authentication(endpoint, rdata)) {
 		pjsip_tx_data *tdata;
 		pjsip_endpt_create_response(ast_sip_get_pjsip_endpoint(), rdata, 401, NULL, &tdata);
 		switch (ast_sip_check_authentication(endpoint, rdata, tdata)) {




More information about the asterisk-commits mailing list