[asterisk-commits] kpfleming: branch kpfleming/via-branch-id-match r225352 - in /team/kpfleming/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 22 07:53:12 CDT 2009


Author: kpfleming
Date: Thu Oct 22 07:53:04 2009
New Revision: 225352

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=225352
Log:
bring up to date and setup for automerging

Modified:
    team/kpfleming/via-branch-id-match/   (props changed)
    team/kpfleming/via-branch-id-match/UPGRADE.txt
    team/kpfleming/via-branch-id-match/apps/app_chanspy.c
    team/kpfleming/via-branch-id-match/apps/app_dial.c
    team/kpfleming/via-branch-id-match/apps/app_fax.c
    team/kpfleming/via-branch-id-match/apps/app_queue.c
    team/kpfleming/via-branch-id-match/apps/app_voicemail.c
    team/kpfleming/via-branch-id-match/cdr/cdr_pgsql.c
    team/kpfleming/via-branch-id-match/cdr/cdr_sqlite3_custom.c
    team/kpfleming/via-branch-id-match/channels/chan_console.c
    team/kpfleming/via-branch-id-match/channels/chan_dahdi.c
    team/kpfleming/via-branch-id-match/channels/chan_h323.c
    team/kpfleming/via-branch-id-match/channels/chan_iax2.c
    team/kpfleming/via-branch-id-match/channels/chan_misdn.c
    team/kpfleming/via-branch-id-match/channels/chan_sip.c
    team/kpfleming/via-branch-id-match/channels/misdn/isdn_lib.c
    team/kpfleming/via-branch-id-match/channels/misdn/isdn_lib_intern.h
    team/kpfleming/via-branch-id-match/channels/misdn_config.c
    team/kpfleming/via-branch-id-match/configs/cdr_custom.conf.sample
    team/kpfleming/via-branch-id-match/configs/iax.conf.sample
    team/kpfleming/via-branch-id-match/configs/queues.conf.sample
    team/kpfleming/via-branch-id-match/configs/res_odbc.conf.sample
    team/kpfleming/via-branch-id-match/configs/sip.conf.sample
    team/kpfleming/via-branch-id-match/configs/udptl.conf.sample
    team/kpfleming/via-branch-id-match/formats/format_siren14.c
    team/kpfleming/via-branch-id-match/funcs/func_dialgroup.c
    team/kpfleming/via-branch-id-match/funcs/func_speex.c
    team/kpfleming/via-branch-id-match/funcs/func_strings.c
    team/kpfleming/via-branch-id-match/include/asterisk/astobj2.h
    team/kpfleming/via-branch-id-match/include/asterisk/file.h
    team/kpfleming/via-branch-id-match/include/asterisk/frame.h
    team/kpfleming/via-branch-id-match/include/asterisk/netsock.h
    team/kpfleming/via-branch-id-match/include/asterisk/rtp.h
    team/kpfleming/via-branch-id-match/main/asterisk.c
    team/kpfleming/via-branch-id-match/main/astobj2.c
    team/kpfleming/via-branch-id-match/main/audiohook.c
    team/kpfleming/via-branch-id-match/main/autoservice.c
    team/kpfleming/via-branch-id-match/main/channel.c
    team/kpfleming/via-branch-id-match/main/features.c
    team/kpfleming/via-branch-id-match/main/file.c
    team/kpfleming/via-branch-id-match/main/frame.c
    team/kpfleming/via-branch-id-match/main/logger.c
    team/kpfleming/via-branch-id-match/main/netsock.c
    team/kpfleming/via-branch-id-match/main/rtp.c
    team/kpfleming/via-branch-id-match/main/say.c
    team/kpfleming/via-branch-id-match/main/udptl.c
    team/kpfleming/via-branch-id-match/res/ael/pval.c
    team/kpfleming/via-branch-id-match/res/res_clialiases.c
    team/kpfleming/via-branch-id-match/res/res_config_pgsql.c
    team/kpfleming/via-branch-id-match/res/res_musiconhold.c
    team/kpfleming/via-branch-id-match/res/res_odbc.c
    team/kpfleming/via-branch-id-match/res/res_phoneprov.c

Propchange: team/kpfleming/via-branch-id-match/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/kpfleming/via-branch-id-match/
------------------------------------------------------------------------------
    automerge-email = kpfleming at digium.com

Propchange: team/kpfleming/via-branch-id-match/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Oct 22 07:53:04 2009
@@ -1,1 +1,1 @@
-/branches/1.6.2:1-221083
+/branches/1.6.2:1-225351

Propchange: team/kpfleming/via-branch-id-match/
------------------------------------------------------------------------------
Binary property 'trunk-blocked' - no diff available.

Propchange: team/kpfleming/via-branch-id-match/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: team/kpfleming/via-branch-id-match/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/team/kpfleming/via-branch-id-match/UPGRADE.txt?view=diff&rev=225352&r1=225351&r2=225352
==============================================================================
--- team/kpfleming/via-branch-id-match/UPGRADE.txt (original)
+++ team/kpfleming/via-branch-id-match/UPGRADE.txt Thu Oct 22 07:53:04 2009
@@ -25,6 +25,18 @@
   install the firmware into its proper location, place the firmware in the
   contrib/firmware/iax/ directory in the Asterisk source tree before running
   "make install".
+
+* T.38 FAX error correction mode can no longer be configured in udptl.conf;
+  instead, it is configured on a per-peer (or global) basis in sip.conf, with
+  the same default as was present in udptl.conf.sample.
+
+* T.38 FAX maximum datagram size can no longer be configured in updtl.conf;
+  instead, it is either supplied by the application servicing the T.38 channel
+  (for a FAX send or receive) or calculated from the bridged endpoint's
+  maximum datagram size (for a T.38 FAX passthrough call). In addition, sip.conf
+  allows for overriding the value supplied by a remote endpoint, which is useful
+  when T.38 connections are made to gateways that supply incorrectly-calculated
+  maximum datagram sizes.
 
 * There have been some changes to the IAX2 protocol to address the security
   concerns documented in the security advisory AST-2009-006.  Please see the

Modified: team/kpfleming/via-branch-id-match/apps/app_chanspy.c
URL: http://svnview.digium.com/svn/asterisk/team/kpfleming/via-branch-id-match/apps/app_chanspy.c?view=diff&rev=225352&r1=225351&r2=225352
==============================================================================
--- team/kpfleming/via-branch-id-match/apps/app_chanspy.c (original)
+++ team/kpfleming/via-branch-id-match/apps/app_chanspy.c Thu Oct 22 07:53:04 2009
@@ -370,7 +370,12 @@
 		return -1;
 	}
 
-	f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR);
+	if (ast_test_flag(chan, OPTION_READONLY)) {
+		/* Option 'o' was set, so don't mix channel audio */
+		f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_READ, AST_FORMAT_SLINEAR);
+	} else {
+		f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR);
+	}
 
 	ast_audiohook_unlock(&csth->spy_audiohook);
 

Modified: team/kpfleming/via-branch-id-match/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/kpfleming/via-branch-id-match/apps/app_dial.c?view=diff&rev=225352&r1=225351&r2=225352
==============================================================================
--- team/kpfleming/via-branch-id-match/apps/app_dial.c (original)
+++ team/kpfleming/via-branch-id-match/apps/app_dial.c Thu Oct 22 07:53:04 2009
@@ -549,7 +549,8 @@
 
 #define CAN_EARLY_BRIDGE(flags,chan,peer) (!ast_test_flag64(flags, OPT_CALLEE_HANGUP | \
 	OPT_CALLER_HANGUP | OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER | \
-	OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR | OPT_CALLEE_PARK | OPT_CALLER_PARK) && \
+	OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR | OPT_CALLEE_PARK |  \
+	OPT_CALLER_PARK | OPT_ANNOUNCE | OPT_CALLEE_MACRO | OPT_CALLEE_GOSUB) && \
 	!chan->audiohooks && !peer->audiohooks)
 
 /*
@@ -753,7 +754,9 @@
 		char *new_cid_num, *new_cid_name;
 		struct ast_channel *src;
 
-		ast_rtp_make_compatible(c, in, single);
+		if (CAN_EARLY_BRIDGE(peerflags, c, in)) {
+			ast_rtp_make_compatible(c, in, single);
+		}
 		if (ast_test_flag64(o, OPT_FORCECLID)) {
 			new_cid_num = ast_strdup(S_OR(in->macroexten, in->exten));
 			new_cid_name = NULL; /* XXX no name ? */
@@ -962,7 +965,9 @@
 					if (single && CAN_EARLY_BRIDGE(peerflags, in, c))
 						ast_channel_early_bridge(in, c);
 					if (!ast_test_flag64(outgoing, OPT_RINGBACK))
-						ast_indicate(in, AST_CONTROL_PROGRESS);
+						if (single || (!single && !pa->sentringing)) {
+							ast_indicate(in, AST_CONTROL_PROGRESS);
+						}
 					break;
 				case AST_CONTROL_VIDUPDATE:
 					ast_verb(3, "%s requested a video update, passing it to %s\n", c->name, in->name);
@@ -1619,7 +1624,7 @@
 		outbound_group = ast_strdupa(outbound_group);
 	}
 	ast_channel_unlock(chan);	
-	ast_copy_flags64(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID | OPT_CALLER_HANGUP | OPT_IGNORE_FORWARDING);
+	ast_copy_flags64(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID | OPT_CALLER_HANGUP | OPT_IGNORE_FORWARDING | OPT_ANNOUNCE | OPT_CALLEE_MACRO | OPT_CALLEE_GOSUB);
 
 	/* loop through the list of dial destinations */
 	rest = args.peers;
@@ -1670,6 +1675,7 @@
 			datastore->inheritance = DATASTORE_INHERIT_FOREVER;
 
 			if (!(dialed_interfaces = ast_calloc(1, sizeof(*dialed_interfaces)))) {
+				ast_datastore_free(datastore);
 				ast_free(tmp);
 				goto out;
 			}
@@ -1729,7 +1735,9 @@
 		pbx_builtin_setvar_helper(tc, "DIALEDPEERNUMBER", numsubst);
 
 		/* Setup outgoing SDP to match incoming one */
-		ast_rtp_make_compatible(tc, chan, !outgoing && !rest);
+		if (CAN_EARLY_BRIDGE(peerflags, chan, tc)) {
+			ast_rtp_make_compatible(tc, chan, !outgoing && !rest);
+		}
 		
 		/* Inherit specially named variables from parent channel */
 		ast_channel_inherit_variables(chan, tc);

Modified: team/kpfleming/via-branch-id-match/apps/app_fax.c
URL: http://svnview.digium.com/svn/asterisk/team/kpfleming/via-branch-id-match/apps/app_fax.c?view=diff&rev=225352&r1=225351&r2=225352
==============================================================================
--- team/kpfleming/via-branch-id-match/apps/app_fax.c (original)
+++ team/kpfleming/via-branch-id-match/apps/app_fax.c Thu Oct 22 07:53:04 2009
@@ -379,8 +379,8 @@
 							     .transcoding_jbig = 1,
 	};
 
-	/* if in receive mode, try to use T.38 */
-	if (!s->direction) {
+	/* if in called party mode, try to use T.38 */
+	if (s->caller_mode == FALSE) {
 		/* check if we are already in T.38 mode (unlikely), or if we can request
 		 * a switch... if so, request it now and wait for the result, rather
 		 * than starting an audio FAX session that will have to be cancelled
@@ -598,6 +598,7 @@
 	struct timeval now, start, state_change, last_frame;
 	t30_state_t *t30state;
 	t38_core_state_t *t38state;
+	struct ast_control_t38_parameters t38_parameters = { .request_response = AST_T38_REQUEST_TERMINATE, };
 
 #if SPANDSP_RELEASE_DATE >= 20080725
 	/* for spandsp shaphots 0.0.6 and higher */
@@ -613,7 +614,8 @@
 	memset(&t38, 0, sizeof(t38));
 	if (t38_terminal_init(&t38, s->caller_mode, t38_tx_packet_handler, s->chan) == NULL) {
 		ast_log(LOG_WARNING, "Unable to start T.38 termination.\n");
-		return -1;
+		res = -1;
+		goto disable_t38;
 	}
 
 	t38_set_max_datagram_size(t38state, s->t38parameters.max_ifp);
@@ -700,6 +702,57 @@
 	t30_terminate(t30state);
 	t38_terminal_release(&t38);
 
+disable_t38:
+	if (ast_channel_get_t38_state(s->chan) == T38_STATE_NEGOTIATED) {
+		if (ast_indicate_data(s->chan, AST_CONTROL_T38_PARAMETERS, &t38_parameters, sizeof(t38_parameters)) == 0) {
+			/* wait up to five seconds for negotiation to complete */
+			unsigned int timeout = 5000;
+			int ms;
+			
+			ast_debug(1, "Shutting down T.38 on %s\n", s->chan->name);
+			while (timeout > 0) {
+				ms = ast_waitfor(s->chan, 1000);
+				if (ms < 0) {
+					ast_log(LOG_WARNING, "something bad happened while channel '%s' was polling.\n", s->chan->name);
+					return -1;
+				}
+				if (!ms) {
+					/* nothing happened */
+					if (timeout > 0) {
+						timeout -= 1000;
+						continue;
+					} else {
+						ast_log(LOG_WARNING, "channel '%s' timed-out during the T.38 shutdown.\n", s->chan->name);
+						break;
+					}
+				}
+				if (!(inf = ast_read(s->chan))) {
+					return -1;
+				}
+				if ((inf->frametype == AST_FRAME_CONTROL) &&
+				    (inf->subclass == AST_CONTROL_T38_PARAMETERS) &&
+				    (inf->datalen == sizeof(t38_parameters))) {
+					struct ast_control_t38_parameters *parameters = inf->data.ptr;
+					
+					switch (parameters->request_response) {
+					case AST_T38_NEGOTIATED:
+						ast_debug(1, "Shut down T.38 on %s\n", s->chan->name);
+						break;
+					case AST_T38_REFUSED:
+						ast_log(LOG_WARNING, "channel '%s' refused to disable T.38\n", s->chan->name);
+						break;
+					default:
+						ast_log(LOG_ERROR, "channel '%s' failed to disable T.38\n", s->chan->name);
+						break;
+					}
+					ast_frfree(inf);
+					break;
+				}
+				ast_frfree(inf);
+			}
+		}
+	}
+
 	return res;
 }
 

Modified: team/kpfleming/via-branch-id-match/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/kpfleming/via-branch-id-match/apps/app_queue.c?view=diff&rev=225352&r1=225351&r2=225352
==============================================================================
--- team/kpfleming/via-branch-id-match/apps/app_queue.c (original)
+++ team/kpfleming/via-branch-id-match/apps/app_queue.c Thu Oct 22 07:53:04 2009
@@ -973,12 +973,14 @@
 			} else {
 				ao2_unlock(q);
 				ao2_ref(member, -1);
+				ao2_iterator_destroy(&mem_iter);
 				ast_debug(4, "%s is available.\n", member->membername);
 				return 0;
 			}
 			break;
 		}
 	}
+	ao2_iterator_destroy(&mem_iter);
 
 	ao2_unlock(q);
 	return -1;
@@ -1030,7 +1032,6 @@
 	int found = 0;
 
 	qiter = ao2_iterator_init(queues, 0);
-
 	while ((q = ao2_iterator_next(&qiter))) {
 		ao2_lock(q);
 
@@ -1049,10 +1050,12 @@
 				break;
 			}
 		}
+		ao2_iterator_destroy(&miter);
 
 		ao2_unlock(q);
 		ao2_ref(q, -1);
 	}
+	ao2_iterator_destroy(&qiter);
 
 	if (found)
 		ast_debug(1, "Device '%s' changed to state '%d' (%s)\n", sc->dev, sc->state, ast_devstate2str(sc->state));
@@ -1232,6 +1235,7 @@
 			mem->calls = 0;
 			ao2_ref(mem, -1);
 		}
+		ao2_iterator_destroy(&mem_iter);
 	}
 }
 
@@ -1590,6 +1594,7 @@
  		}
  		ao2_ref(m, -1);
  	}
+	ao2_iterator_destroy(&mem_iter);
 
  	/* Create a new member */
  	if (!found) {
@@ -1620,6 +1625,7 @@
 		}
 		ao2_ref(cur, -1);
 	}
+	ao2_iterator_destroy(&mem_iter);
 }
 
 /*! \brief Free queue's member list then its string fields */
@@ -1768,6 +1774,7 @@
 			m->dead = 1;
 		ao2_ref(m, -1);
 	}
+	ao2_iterator_destroy(&mem_iter);
 
 	while ((interface = ast_category_browse(member_config, interface))) {
 		rt_handle_member_record(q, interface,
@@ -1788,6 +1795,7 @@
 		}
 		ao2_ref(m, -1);
 	}
+	ao2_iterator_destroy(&mem_iter);
 
 	ao2_unlock(q);
 
@@ -1893,6 +1901,7 @@
 			m->dead = 1;
 		ao2_ref(m, -1);
 	}
+	ao2_iterator_destroy(&mem_iter);
 
 	while ((interface = ast_category_browse(member_config, interface))) {
 		rt_handle_member_record(q, interface,
@@ -1913,6 +1922,7 @@
 		}
 		ao2_ref(m, -1);
 	}
+	ao2_iterator_destroy(&mem_iter);
 	ao2_unlock(q);
 	ao2_unlock(queues);
 	ast_config_destroy(member_config);
@@ -2326,6 +2336,7 @@
 			break;
 		}
 	}
+	ao2_iterator_destroy(&mem_iter);
 
 	return avl;
 }
@@ -2364,6 +2375,7 @@
 			break;
 		}
 	}
+	ao2_iterator_destroy(&queue_iter);
 	return found;
 }
 
@@ -2711,7 +2723,7 @@
 
 	ast_verb(3, "Playing periodic announcement\n");
 	
-	if (qe->parent->randomperiodicannounce) {
+	if (qe->parent->randomperiodicannounce && qe->parent->numperiodicannounce) {
 		qe->last_periodic_announce_sound = ((unsigned long) ast_random()) % qe->parent->numperiodicannounce;
 	} else if (qe->last_periodic_announce_sound >= qe->parent->numperiodicannounce || 
 		ast_str_strlen(qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound]) == 0) {
@@ -3250,6 +3262,7 @@
 			ao2_unlock(qtmp);
 			ao2_ref(qtmp, -1);
 		}
+		ao2_iterator_destroy(&queue_iter);
 	} else {
 		ao2_lock(q);
 		time(&member->lastcall);
@@ -3667,6 +3680,7 @@
 		if (!tmp) {
 			ao2_ref(cur, -1);
 			ao2_unlock(qe->parent);
+			ao2_iterator_destroy(&memi);
 			if (use_weight)
 				ao2_unlock(queues);
 			goto out;
@@ -3675,6 +3689,7 @@
 			if (!(datastore = ast_datastore_alloc(&dialed_interface_info, NULL))) {
 				ao2_ref(cur, -1);
 				ao2_unlock(qe->parent);
+				ao2_iterator_destroy(&memi);
 				if (use_weight)
 					ao2_unlock(queues);
 				free(tmp);
@@ -3684,6 +3699,7 @@
 			if (!(dialed_interfaces = ast_calloc(1, sizeof(*dialed_interfaces)))) {
 				ao2_ref(cur, -1);
 				ao2_unlock(&qe->parent);
+				ao2_iterator_destroy(&memi);
 				if (use_weight)
 					ao2_unlock(queues);
 				free(tmp);
@@ -3721,6 +3737,7 @@
 			if (!(di = ast_calloc(1, sizeof(*di) + strlen(cur->interface)))) {
 				ao2_ref(cur, -1);
 				ao2_unlock(qe->parent);
+				ao2_iterator_destroy(&memi);
 				if (use_weight)
 					ao2_unlock(queues);
 				free(tmp);
@@ -3755,6 +3772,7 @@
 			ast_free(tmp);
 		}
 	}
+	ao2_iterator_destroy(&memi);
 
 	if (qe->parent->timeoutpriority == TIMEOUT_PRIORITY_APP) {
 		/* Application arguments have higher timeout priority (behaviour for <=1.6) */
@@ -4294,10 +4312,13 @@
 
 	mem_iter = ao2_iterator_init(q->members, 0);
 	while ((mem = ao2_iterator_next(&mem_iter))) {
-		if (!strcasecmp(interface, mem->interface))
+		if (!strcasecmp(interface, mem->interface)) {
+			ao2_iterator_destroy(&mem_iter);
 			return mem;
+		}
 		ao2_ref(mem, -1);
 	}
+	ao2_iterator_destroy(&mem_iter);
 
 	return NULL;
 }
@@ -4338,6 +4359,7 @@
 		}
 		value_len += res;
 	}
+	ao2_iterator_destroy(&mem_iter);
 	
 	if (value_len && !cur_member) {
 		if (ast_db_put(pm_family, pm_queue->name, value))
@@ -4529,6 +4551,7 @@
 		ao2_unlock(q);
 		queue_unref(q);
 	}
+	ao2_iterator_destroy(&queue_iter);
 
 	return found ? RESULT_SUCCESS : RESULT_FAILURE;
 }
@@ -4567,6 +4590,7 @@
 		ao2_unlock(q);
 		queue_unref(q);
 	}
+	ao2_iterator_destroy(&queue_iter);
 
 	if (foundinterface) {
 		return RESULT_SUCCESS;
@@ -5334,6 +5358,7 @@
 				}
 				ao2_ref(m, -1);
 			}
+			ao2_iterator_destroy(&mem_iter);
 		} else if (!strcasecmp(option, "free")) {
 			mem_iter = ao2_iterator_init(q->members, 0);
 			while ((m = ao2_iterator_next(&mem_iter))) {
@@ -5343,6 +5368,7 @@
 				}
 				ao2_ref(m, -1);
 			}
+			ao2_iterator_destroy(&mem_iter);
 		} else /* must be "count" */
 			count = q->membercount;
 		ao2_unlock(q);
@@ -5388,6 +5414,7 @@
 			}
 			ao2_ref(m, -1);
 		}
+		ao2_iterator_destroy(&mem_iter);
 		ao2_unlock(q);
 		queue_unref(q);
 	} else
@@ -5471,6 +5498,7 @@
 			}
 			ao2_ref(m, -1);
 		}
+		ao2_iterator_destroy(&mem_iter);
 		ao2_unlock(q);
 		queue_unref(q);
 	} else
@@ -5971,6 +5999,7 @@
 			clear_queue(q);
 		ao2_unlock(q);
 	}
+	ao2_iterator_destroy(&queue_iter);
 	return 0;
 }
 
@@ -6050,7 +6079,7 @@
 		}
 	}
 
-	queue_iter = ao2_iterator_init(queues, F_AO2I_DONTLOCK);
+	queue_iter = ao2_iterator_init(queues, AO2_ITERATOR_DONTLOCK);
 	ao2_lock(queues);
 	while ((q = ao2_iterator_next(&queue_iter))) {
 		float sl;
@@ -6114,6 +6143,7 @@
 				do_print(s, fd, ast_str_buffer(out));
 				ao2_ref(mem, -1);
 			}
+			ao2_iterator_destroy(&mem_iter);
 		}
 		if (!q->head)
 			do_print(s, fd, "   No Callers");
@@ -6133,6 +6163,7 @@
 		ao2_unlock(q);
 		queue_unref(q); /* Unref the iterator's reference */
 	}
+	ao2_iterator_destroy(&queue_iter);
 	ao2_unlock(queues);
 	if (!found) {
 		if (argc == 3)
@@ -6161,6 +6192,7 @@
 		}
 		queue_unref(q);
 	}
+	ao2_iterator_destroy(&queue_iter);
 
 	return ret;
 }
@@ -6269,6 +6301,7 @@
 				}
 				ao2_ref(mem, -1);
 			}
+			ao2_iterator_destroy(&mem_iter);
 			for (qe = q->head; qe; qe = qe->next) {
 				if ((now - qe->start) > qlongestholdtime) {
 					qlongestholdtime = now - qe->start;
@@ -6290,6 +6323,7 @@
 		ao2_unlock(q);
 		queue_unref(q);
 	}
+	ao2_iterator_destroy(&queue_iter);
 	astman_append(s,
 		"Event: QueueSummaryComplete\r\n"
 		"%s"
@@ -6363,6 +6397,7 @@
 				}
 				ao2_ref(mem, -1);
 			}
+			ao2_iterator_destroy(&mem_iter);
 			/* List Queue Entries */
 			pos = 1;
 			for (qe = q->head; qe; qe = qe->next) {
@@ -6385,6 +6420,7 @@
 		ao2_unlock(q);
 		queue_unref(q);
 	}
+	ao2_iterator_destroy(&queue_iter);
 
 	astman_append(s,
 		"Event: QueueStatusComplete\r\n"
@@ -6731,13 +6767,17 @@
 				tmp = ast_strdup(m->interface);
 				ao2_ref(m, -1);
 				queue_unref(q);
+				ao2_iterator_destroy(&mem_iter);
+				ao2_iterator_destroy(&queue_iter);
 				return tmp;
 			}
 			ao2_ref(m, -1);
 		}
+		ao2_iterator_destroy(&mem_iter);
 		ao2_unlock(q);
 		queue_unref(q);
 	}
+	ao2_iterator_destroy(&queue_iter);
 
 	return NULL;
 }
@@ -7137,6 +7177,7 @@
 		ao2_unlink(queues, q);
 		queue_unref(q);
 	}
+	ao2_iterator_destroy(&q_iter);
 	ao2_ref(queues, -1);
 	devicestate_tps = ast_taskprocessor_unreference(devicestate_tps);
 	ast_unload_realtime("queue_members");

Modified: team/kpfleming/via-branch-id-match/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/kpfleming/via-branch-id-match/apps/app_voicemail.c?view=diff&rev=225352&r1=225351&r2=225352
==============================================================================
--- team/kpfleming/via-branch-id-match/apps/app_voicemail.c (original)
+++ team/kpfleming/via-branch-id-match/apps/app_voicemail.c Thu Oct 22 07:53:04 2009
@@ -221,7 +221,19 @@
 					<option name="a">
 						<argument name="folder" required="true" />
 						<para>Skip folder prompt and go directly to <replaceable>folder</replaceable> specified.
-						Defaults to <literal>INBOX</literal>.</para>
+						Defaults to <literal>0</literal> (INBOX).</para>
+						<enumlist>
+							<enum name="0"><para>INBOX</para></enum>
+							<enum name="1"><para>Old</para></enum>
+							<enum name="2"><para>Work</para></enum>
+							<enum name="3"><para>Family</para></enum>
+							<enum name="4"><para>Friends</para></enum>
+							<enum name="5"><para>Cust1</para></enum>
+							<enum name="6"><para>Cust2</para></enum>
+							<enum name="7"><para>Cust3</para></enum>
+							<enum name="8"><para>Cust4</para></enum>
+							<enum name="9"><para>Cust5</para></enum>
+						</enumlist>
 					</option>
 				</optionlist>
 			</parameter>
@@ -4575,16 +4587,15 @@
 }
 
 #ifdef ODBC_STORAGE
-/*! XXX \todo Fix this function to support multiple mailboxes in the intput string */
 static int inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs)
 {
 	int x = -1;
 	int res;
-	SQLHSTMT stmt;
+	SQLHSTMT stmt = NULL;
 	char sql[PATH_MAX];
 	char rowdata[20];
 	char tmp[PATH_MAX] = "";
-	struct odbc_obj *obj;
+	struct odbc_obj *obj = NULL;
 	char *context;
 	struct generic_prepare_struct gps = { .sql = sql, .argc = 0 };
 
@@ -4600,99 +4611,108 @@
 		return 0;
 
 	ast_copy_string(tmp, mailbox, sizeof(tmp));
-	
+
+	if (strchr(mailbox, ' ') || strchr(mailbox, ',')) {
+		int u, n, o;
+		char *next, *remaining = tmp;
+		while ((next = strsep(&remaining, " ,"))) {
+			if (inboxcount2(next, urgentmsgs ? &u : NULL, &n, &o)) {
+				return -1;
+			}
+			if (urgentmsgs) {
+				*urgentmsgs += u;
+			}
+			if (newmsgs) {
+				*newmsgs += n;
+			}
+			if (oldmsgs) {
+				*oldmsgs += o;
+			}
+		}
+		return 0;
+	}
+
 	context = strchr(tmp, '@');
 	if (context) {
 		*context = '\0';
 		context++;
 	} else
 		context = "default";
-	
-	obj = ast_odbc_request_obj(odbc_database, 0);
+
+	if ((obj = ast_odbc_request_obj(odbc_database, 0))) {
+		do {
+			if (newmsgs) {
+				snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir = '%s%s/%s/%s'", odbc_table, VM_SPOOL_DIR, context, tmp, "INBOX");
+				if (!(stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps))) {
+					ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
+					break;
+				}
+				res = SQLFetch(stmt);
+				if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
+					ast_log(AST_LOG_WARNING, "SQL Fetch error!\n[%s]\n\n", sql);
+					break;
+				}
+				res = SQLGetData(stmt, 1, SQL_CHAR, rowdata, sizeof(rowdata), NULL);
+				if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
+					ast_log(AST_LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
+					break;
+				}
+				*newmsgs = atoi(rowdata);
+				SQLFreeHandle (SQL_HANDLE_STMT, stmt);
+			}
+
+			if (oldmsgs) {
+				snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir = '%s%s/%s/%s'", odbc_table, VM_SPOOL_DIR, context, tmp, "Old");
+				if (!(stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps))) {
+					ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
+					break;
+				}
+				res = SQLFetch(stmt);
+				if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
+					ast_log(AST_LOG_WARNING, "SQL Fetch error!\n[%s]\n\n", sql);
+					break;
+				}
+				res = SQLGetData(stmt, 1, SQL_CHAR, rowdata, sizeof(rowdata), NULL);
+				if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
+					ast_log(AST_LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
+					break;
+				}
+				SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+				*oldmsgs = atoi(rowdata);
+			}
+
+			if (urgentmsgs) {
+				snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir = '%s%s/%s/%s'", odbc_table, VM_SPOOL_DIR, context, tmp, "Urgent");
+				if (!(stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps))) {
+					ast_log(LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
+					break;
+				}
+				res = SQLFetch(stmt);
+				if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
+					ast_log(LOG_WARNING, "SQL Fetch error!\n[%s]\n\n", sql);
+					break;
+				}
+				res = SQLGetData(stmt, 1, SQL_CHAR, rowdata, sizeof(rowdata), NULL);
+				if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
+					ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
+					break;
+				}
+				*urgentmsgs = atoi(rowdata);
+			}
+
+			x = 0;
+		} while (0);
+	} else {
+		ast_log(AST_LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
+	}
+
+	if (stmt) {
+		SQLFreeHandle (SQL_HANDLE_STMT, stmt);
+	}
 	if (obj) {
-		snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir = '%s%s/%s/%s'", odbc_table, VM_SPOOL_DIR, context, tmp, "INBOX");
-		stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
-		if (!stmt) {
-			ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
-			ast_odbc_release_obj(obj);
-			goto yuck;
-		}
-		res = SQLFetch(stmt);
-		if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
-			ast_log(AST_LOG_WARNING, "SQL Fetch error!\n[%s]\n\n", sql);
-			SQLFreeHandle (SQL_HANDLE_STMT, stmt);
-			ast_odbc_release_obj(obj);
-			goto yuck;
-		}
-		res = SQLGetData(stmt, 1, SQL_CHAR, rowdata, sizeof(rowdata), NULL);
-		if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
-			ast_log(AST_LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
-			SQLFreeHandle (SQL_HANDLE_STMT, stmt);
-			ast_odbc_release_obj(obj);
-			goto yuck;
-		}
-		*newmsgs = atoi(rowdata);
-		SQLFreeHandle (SQL_HANDLE_STMT, stmt);
-
-		snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir = '%s%s/%s/%s'", odbc_table, VM_SPOOL_DIR, context, tmp, "Old");
-		stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
-		if (!stmt) {
-			ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
-			ast_odbc_release_obj(obj);
-			goto yuck;
-		}
-		res = SQLFetch(stmt);
-		if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
-			ast_log(AST_LOG_WARNING, "SQL Fetch error!\n[%s]\n\n", sql);
-			SQLFreeHandle (SQL_HANDLE_STMT, stmt);
-			ast_odbc_release_obj(obj);
-			goto yuck;
-		}
-		res = SQLGetData(stmt, 1, SQL_CHAR, rowdata, sizeof(rowdata), NULL);
-		if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
-			ast_log(AST_LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
-			SQLFreeHandle (SQL_HANDLE_STMT, stmt);
-			ast_odbc_release_obj(obj);
-			goto yuck;
-		}
-		SQLFreeHandle (SQL_HANDLE_STMT, stmt);
-		*oldmsgs = atoi(rowdata);
-
-		if (!urgentmsgs) {
-			x = 0;
-			ast_odbc_release_obj(obj);
-			goto yuck;
-		}
-
-		snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir = '%s%s/%s/%s'", odbc_table, VM_SPOOL_DIR, context, tmp, "Urgent");
-		stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
-		if (!stmt) {
-			ast_log(LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
-			ast_odbc_release_obj(obj);
-			goto yuck;
-		}
-		res = SQLFetch(stmt);
-		if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
-			ast_log(LOG_WARNING, "SQL Fetch error!\n[%s]\n\n", sql);
-			SQLFreeHandle (SQL_HANDLE_STMT, stmt);
-			ast_odbc_release_obj(obj);
-			goto yuck;
-		}
-		res = SQLGetData(stmt, 1, SQL_CHAR, rowdata, sizeof(rowdata), NULL);
-		if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
-			ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
-			SQLFreeHandle (SQL_HANDLE_STMT, stmt);
-			ast_odbc_release_obj(obj);
-			goto yuck;
-		}
-		*urgentmsgs = atoi(rowdata);
-		SQLFreeHandle (SQL_HANDLE_STMT, stmt);
 		ast_odbc_release_obj(obj);
-		x = 0;
-	} else
-		ast_log(AST_LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database);
-		
-yuck:	
+	}
+
 	return x;
 }
 

Modified: team/kpfleming/via-branch-id-match/cdr/cdr_pgsql.c
URL: http://svnview.digium.com/svn/asterisk/team/kpfleming/via-branch-id-match/cdr/cdr_pgsql.c?view=diff&rev=225352&r1=225351&r2=225352
==============================================================================
--- team/kpfleming/via-branch-id-match/cdr/cdr_pgsql.c (original)
+++ team/kpfleming/via-branch-id-match/cdr/cdr_pgsql.c Thu Oct 22 07:53:04 2009
@@ -467,22 +467,58 @@
 
 	conn = PQsetdbLogin(pghostname, pgdbport, NULL, NULL, pgdbname, pgdbuser, pgpassword);
 	if (PQstatus(conn) != CONNECTION_BAD) {
-		char sqlcmd[512];
+		char sqlcmd[768];
 		char *fname, *ftype, *flen, *fnotnull, *fdef;
-		char *tableptr;
-		int i, rows;
+		int i, rows, version;
 		ast_debug(1, "Successfully connected to PostgreSQL database.\n");
 		connected = 1;
-
-		/* Remove any schema name from the table */
-		if ((tableptr = strrchr(table, '.'))) {
-			tableptr++;
+		version = PQserverVersion(conn);
+
+		if (version >= 70300) {
+			char *schemaname, *tablename;
+			if (strchr(table, '.')) {
+				schemaname = ast_strdupa(table);
+				tablename = strchr(schemaname, '.');
+				*tablename++ = '\0';
+			} else {
+				schemaname = "";
+				tablename = table;
+			}
+
+			/* Escape special characters in schemaname */
+			if (strchr(schemaname, '\\') || strchr(schemaname, '\'')) {
+				char *tmp = schemaname, *ptr;
+
+				ptr = schemaname = alloca(strlen(tmp) * 2 + 1);
+				for (; *tmp; tmp++) {
+					if (strchr("\\'", *tmp)) {
+						*ptr++ = *tmp;
+					}
+					*ptr++ = *tmp;
+				}
+				*ptr = '\0';
+			}
+			/* Escape special characters in tablename */
+			if (strchr(tablename, '\\') || strchr(tablename, '\'')) {
+				char *tmp = tablename, *ptr;
+
+				ptr = tablename = alloca(strlen(tmp) * 2 + 1);
+				for (; *tmp; tmp++) {
+					if (strchr("\\'", *tmp)) {
+						*ptr++ = *tmp;
+					}
+					*ptr++ = *tmp;
+				}
+				*ptr = '\0';
+			}
+
+			snprintf(sqlcmd, sizeof(sqlcmd), "SELECT a.attname, t.typname, a.attlen, a.attnotnull, d.adsrc, a.atttypmod FROM (((pg_catalog.pg_class c INNER JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace AND c.relname = '%s' AND n.nspname = %s%s%s) INNER JOIN pg_catalog.pg_attribute a ON (NOT a.attisdropped) AND a.attnum > 0 AND a.attrelid = c.oid) INNER JOIN pg_catalog.pg_type t ON t.oid = a.atttypid) LEFT OUTER JOIN pg_attrdef d ON a.atthasdef AND d.adrelid = a.attrelid AND d.adnum = a.attnum ORDER BY n.nspname, c.relname, attnum",
+				tablename,
+				ast_strlen_zero(schemaname) ? "" : "'", ast_strlen_zero(schemaname) ? "current_schema()" : schemaname, ast_strlen_zero(schemaname) ? "" : "'");
 		} else {
-			tableptr = table;
-		}
-
+			snprintf(sqlcmd, sizeof(sqlcmd), "SELECT a.attname, t.typname, a.attlen, a.attnotnull, d.adsrc, a.atttypmod FROM pg_class c, pg_type t, pg_attribute a LEFT OUTER JOIN pg_attrdef d ON a.atthasdef AND d.adrelid = a.attrelid AND d.adnum = a.attnum WHERE c.oid = a.attrelid AND a.atttypid = t.oid AND (a.attnum > 0) AND c.relname = '%s' ORDER BY c.relname, attnum", table);
+		}
 		/* Query the columns */
-		snprintf(sqlcmd, sizeof(sqlcmd), "select a.attname, t.typname, a.attlen, a.attnotnull, d.adsrc from pg_class c, pg_type t, pg_attribute a left outer join pg_attrdef d on a.atthasdef and d.adrelid = a.attrelid and d.adnum = a.attnum where c.oid = a.attrelid and a.atttypid = t.oid and (a.attnum > 0) and c.relname = '%s' order by c.relname, attnum", tableptr);
 		result = PQexec(conn, sqlcmd);
 		if (PQresultStatus(result) != PGRES_TUPLES_OK) {
 			pgerror = PQresultErrorMessage(result);
@@ -499,6 +535,10 @@
 			flen = PQgetvalue(result, i, 2);
 			fnotnull = PQgetvalue(result, i, 3);
 			fdef = PQgetvalue(result, i, 4);
+			if (atoi(flen) == -1) {
+				/* For varchar columns, the maximum length is encoded in a different field */
+				flen = PQgetvalue(result, i, 5);
+			}
 			ast_verb(4, "Found column '%s' of type '%s'\n", fname, ftype);
 			cur = ast_calloc(1, sizeof(*cur) + strlen(fname) + strlen(ftype) + 2);
 			if (cur) {

Modified: team/kpfleming/via-branch-id-match/cdr/cdr_sqlite3_custom.c
URL: http://svnview.digium.com/svn/asterisk/team/kpfleming/via-branch-id-match/cdr/cdr_sqlite3_custom.c?view=diff&rev=225352&r1=225351&r2=225352
==============================================================================
--- team/kpfleming/via-branch-id-match/cdr/cdr_sqlite3_custom.c (original)
+++ team/kpfleming/via-branch-id-match/cdr/cdr_sqlite3_custom.c Thu Oct 22 07:53:04 2009
@@ -70,7 +70,7 @@
 
 static AST_LIST_HEAD_STATIC(sql_values, values);
 
-static void free_config(void);
+static void free_config(int reload);
 
 static int load_column_config(const char *tmp)
 {
@@ -163,7 +163,7 @@
 	}
 
 	if (reload) {
-		free_config();
+		free_config(1);
 	}
 
 	if (!(mappingvar = ast_variable_browse(cfg, "master"))) {
@@ -183,14 +183,14 @@
 	/* Columns */
 	if (load_column_config(ast_variable_retrieve(cfg, "master", "columns"))) {
 		ast_config_destroy(cfg);
-		free_config();
+		free_config(0);
 		return -1;
 	}
 
 	/* Values */
 	if (load_values_config(ast_variable_retrieve(cfg, "master", "values"))) {
 		ast_config_destroy(cfg);
-		free_config();
+		free_config(0);
 		return -1;
 	}
 
@@ -201,11 +201,11 @@
 	return 0;
 }
 
-static void free_config(void)
+static void free_config(int reload)
 {
 	struct values *value;
 
-	if (db) {
+	if (!reload && db) {
 		sqlite3_close(db);
 		db = NULL;
 	}
@@ -279,7 +279,7 @@
 {
 	ast_cdr_unregister(name);
 
-	free_config();
+	free_config(0);
 
 	return 0;
 }
@@ -300,7 +300,7 @@
 	res = sqlite3_open(filename, &db);
 	if (res != SQLITE_OK) {
 		ast_log(LOG_ERROR, "Could not open database %s.\n", filename);
-		free_config();
+		free_config(0);
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
@@ -316,7 +316,7 @@
 		if (res != SQLITE_OK) {
 			ast_log(LOG_WARNING, "Unable to create table '%s': %s.\n", table, error);
 			sqlite3_free(error);
-			free_config();
+			free_config(0);
 			return AST_MODULE_LOAD_DECLINE;
 		}
 	}
@@ -324,7 +324,7 @@
 	res = ast_cdr_register(name, desc, sqlite3_log);
 	if (res) {
 		ast_log(LOG_ERROR, "Unable to register custom SQLite3 CDR handling\n");
-		free_config();
+		free_config(0);
 		return AST_MODULE_LOAD_DECLINE;
 	}
 

Modified: team/kpfleming/via-branch-id-match/channels/chan_console.c
URL: http://svnview.digium.com/svn/asterisk/team/kpfleming/via-branch-id-match/channels/chan_console.c?view=diff&rev=225352&r1=225351&r2=225352
==============================================================================
--- team/kpfleming/via-branch-id-match/channels/chan_console.c (original)
+++ team/kpfleming/via-branch-id-match/channels/chan_console.c Thu Oct 22 07:53:04 2009
@@ -1020,6 +1020,7 @@
 		console_pvt_unlock(pvt);
 		unref_pvt(pvt);
 	}
+	ao2_iterator_destroy(&i);
 
 	ast_cli(a->fd, "=============================================================\n\n");
 
@@ -1169,9 +1170,12 @@
 				if (++x > a->n && !strncasecmp(pvt->name, a->word, strlen(a->word)))
 					res = ast_strdup(pvt->name);
 				unref_pvt(pvt);
-				if (res)
+				if (res) {
+					ao2_iterator_destroy(&i);
 					return res;
+				}
 			}
+			ao2_iterator_destroy(&i);
 		}
 		return NULL;
 	}
@@ -1374,6 +1378,7 @@
 		}
 		unref_pvt(pvt);
 	}
+	ao2_iterator_destroy(&i);
 }
 
 /*!
@@ -1447,6 +1452,7 @@
 			stop_stream(pvt);
 		unref_pvt(pvt);
 	}
+	ao2_iterator_destroy(&i);
 }
 
 static int unload_module(void)

Modified: team/kpfleming/via-branch-id-match/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/kpfleming/via-branch-id-match/channels/chan_dahdi.c?view=diff&rev=225352&r1=225351&r2=225352
==============================================================================
--- team/kpfleming/via-branch-id-match/channels/chan_dahdi.c (original)
+++ team/kpfleming/via-branch-id-match/channels/chan_dahdi.c Thu Oct 22 07:53:04 2009
@@ -3813,7 +3813,8 @@
 				redirect_reason = 0;
 			else if (!strcasecmp(rr_str, "BUSY"))
 				redirect_reason = 1;
-			else if (!strcasecmp(rr_str, "NO_REPLY"))
+			else if (!strcasecmp(rr_str, "NO_REPLY") || !strcasecmp(rr_str, "NOANSWER"))
+			/* the NOANSWER is to match diversion-reason from chan_sip, (which never reads PRIREDIRECTREASON) */
 				redirect_reason = 2;
 			else if (!strcasecmp(rr_str, "UNCONDITIONAL"))
 				redirect_reason = 15;
@@ -3859,8 +3860,9 @@
 		ast_smdi_interface_unref(p->smdi_iface);
 	if (p->mwi_event_sub)
 		ast_event_unsubscribe(p->mwi_event_sub);
-	if (p->vars)
+	if (p->vars) {
 		ast_variables_destroy(p->vars);
+	}
 	ast_mutex_destroy(&p->lock);
 	dahdi_close_sub(p, SUB_REAL);
 	if (p->owner)
@@ -4326,6 +4328,8 @@
 	if ((p->sig == SIG_PRI) || (p->sig == SIG_SS7) || (p->sig == SIG_BRI) || (p->sig == SIG_BRI_PTMP)) {
 		x = 1;
 		ast_channel_setoption(ast,AST_OPTION_AUDIO_MODE,&x,sizeof(char),0);
+		p->cid_num[0] = '\0';
+		p->cid_name[0] = '\0';
 	}
 
 	x = 0;
@@ -4520,6 +4524,8 @@
 		}
 #endif
 #ifdef HAVE_OPENR2
+		p->cid_num[0] = '\0';
+		p->cid_name[0] = '\0';
 		if (p->mfcr2 && p->mfcr2call && openr2_chan_get_direction(p->r2chan) != OR2_DIR_STOPPED) {
 			ast_log(LOG_DEBUG, "disconnecting MFC/R2 call on chan %d\n", p->channel);
 			/* If it's an incoming call, check the mfcr2_forced_release setting */
@@ -6724,7 +6730,10 @@
 		return NULL;
 	}
 
-	if ((p->radio || (p->oprmode < 0)) && p->inalarm) return NULL;
+	if ((p->radio || (p->oprmode < 0)) && p->inalarm) {
+		ast_mutex_unlock(&p->lock);
+		return NULL;
+	}
 
 	p->subs[idx].f.frametype = AST_FRAME_NULL;
 	p->subs[idx].f.datalen = 0;
@@ -7023,6 +7032,7 @@
 							if (res < 0) {
 								ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", p->channel);
 								p->dop.dialstr[0] = '\0';
+								ast_mutex_unlock(&p->lock);
 								return NULL;
 							} else {
 								ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", p->dop.dialstr);
@@ -10460,10 +10470,15 @@
 		ast_copy_string(tmp->mohinterpret, conf->chan.mohinterpret, sizeof(tmp->mohinterpret));
 		ast_copy_string(tmp->mohsuggest, conf->chan.mohsuggest, sizeof(tmp->mohsuggest));
 		ast_copy_string(tmp->context, conf->chan.context, sizeof(tmp->context));
-		ast_copy_string(tmp->cid_num, conf->chan.cid_num, sizeof(tmp->cid_num));
 		ast_copy_string(tmp->parkinglot, conf->chan.parkinglot, sizeof(tmp->parkinglot));
 		tmp->cid_ton = 0;
-		ast_copy_string(tmp->cid_name, conf->chan.cid_name, sizeof(tmp->cid_name));
+		if ((tmp->sig != SIG_PRI) || (tmp->sig != SIG_SS7) || (tmp->sig != SIG_BRI) || (tmp->sig != SIG_BRI_PTMP) || (tmp->sig != SIG_MFCR2)) {
+			ast_copy_string(tmp->cid_num, conf->chan.cid_num, sizeof(tmp->cid_num));
+			ast_copy_string(tmp->cid_name, conf->chan.cid_name, sizeof(tmp->cid_name));
+		} else {
+			tmp->cid_num[0] = '\0';
+			tmp->cid_name[0] = '\0';
+		}
 		ast_copy_string(tmp->mailbox, conf->chan.mailbox, sizeof(tmp->mailbox));
 		if (channel != CHAN_PSEUDO && !ast_strlen_zero(tmp->mailbox)) {
 			char *mailbox, *context;
@@ -10498,7 +10513,7 @@
 		tmp->callgroup = conf->chan.callgroup;
 		tmp->pickupgroup= conf->chan.pickupgroup;
 		if (conf->chan.vars) {
-			tmp->vars = conf->chan.vars;

[... 3817 lines stripped ...]



More information about the asterisk-commits mailing list