[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r302459 - in /team/dvossel/f...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 19 10:33:04 CST 2011


Author: dvossel
Date: Wed Jan 19 10:32:54 2011
New Revision: 302459

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=302459
Log:
adds the ability to allocate format containers with internal locking

Modified:
    team/dvossel/fixtheworld_phase1_step3/apps/app_confbridge.c
    team/dvossel/fixtheworld_phase1_step3/apps/app_meetme.c
    team/dvossel/fixtheworld_phase1_step3/apps/app_originate.c
    team/dvossel/fixtheworld_phase1_step3/apps/app_parkandannounce.c
    team/dvossel/fixtheworld_phase1_step3/apps/app_rpt.c
    team/dvossel/fixtheworld_phase1_step3/bridges/bridge_multiplexed.c
    team/dvossel/fixtheworld_phase1_step3/bridges/bridge_simple.c
    team/dvossel/fixtheworld_phase1_step3/bridges/bridge_softmix.c
    team/dvossel/fixtheworld_phase1_step3/channels/chan_agent.c
    team/dvossel/fixtheworld_phase1_step3/channels/chan_alsa.c
    team/dvossel/fixtheworld_phase1_step3/channels/chan_bridge.c
    team/dvossel/fixtheworld_phase1_step3/channels/chan_console.c
    team/dvossel/fixtheworld_phase1_step3/channels/chan_dahdi.c
    team/dvossel/fixtheworld_phase1_step3/channels/chan_gtalk.c
    team/dvossel/fixtheworld_phase1_step3/channels/chan_h323.c
    team/dvossel/fixtheworld_phase1_step3/channels/chan_iax2.c
    team/dvossel/fixtheworld_phase1_step3/channels/chan_jingle.c
    team/dvossel/fixtheworld_phase1_step3/channels/chan_local.c
    team/dvossel/fixtheworld_phase1_step3/channels/chan_oss.c
    team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/rtp_engine.h
    team/dvossel/fixtheworld_phase1_step3/main/ccss.c
    team/dvossel/fixtheworld_phase1_step3/main/channel.c
    team/dvossel/fixtheworld_phase1_step3/main/dial.c
    team/dvossel/fixtheworld_phase1_step3/main/features.c
    team/dvossel/fixtheworld_phase1_step3/main/file.c
    team/dvossel/fixtheworld_phase1_step3/main/format_cap.c
    team/dvossel/fixtheworld_phase1_step3/main/manager.c
    team/dvossel/fixtheworld_phase1_step3/main/rtp_engine.c
    team/dvossel/fixtheworld_phase1_step3/pbx/pbx_spool.c
    team/dvossel/fixtheworld_phase1_step3/res/res_agi.c
    team/dvossel/fixtheworld_phase1_step3/res/res_clioriginate.c
    team/dvossel/fixtheworld_phase1_step3/tests/test_format_api.c

Modified: team/dvossel/fixtheworld_phase1_step3/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/apps/app_confbridge.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/apps/app_confbridge.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/apps/app_confbridge.c Wed Jan 19 10:32:54 2011
@@ -567,7 +567,7 @@
 
 	if (!(conference_bridge->playback_chan)) {
 		int cause;
-		struct ast_format_cap *cap = ast_format_cap_alloc();
+		struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
 		struct ast_format tmpfmt;
 		if (!cap) {
 			return -1;

Modified: team/dvossel/fixtheworld_phase1_step3/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/apps/app_meetme.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/apps/app_meetme.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/apps/app_meetme.c Wed Jan 19 10:32:54 2011
@@ -1189,7 +1189,7 @@
 	struct ast_conference *cnf;
 	struct dahdi_confinfo dahdic = { 0, };
 	int confno_int = 0;
-	struct ast_format_cap *cap_slin = ast_format_cap_alloc();
+	struct ast_format_cap *cap_slin = ast_format_cap_alloc_nolock();
 	struct ast_format tmp_fmt;
 
 	AST_LIST_LOCK(&confs);
@@ -2256,7 +2256,7 @@
 	int setusercount = 0;
 	int confsilence = 0, totalsilence = 0;
 	char *mailbox, *context;
-	struct ast_format_cap *cap_slin = ast_format_cap_alloc();
+	struct ast_format_cap *cap_slin = ast_format_cap_alloc_nolock();
 	struct ast_format tmpfmt;
 
 	if (!cap_slin) {

Modified: team/dvossel/fixtheworld_phase1_step3/apps/app_originate.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/apps/app_originate.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/apps/app_originate.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/apps/app_originate.c Wed Jan 19 10:32:54 2011
@@ -106,7 +106,7 @@
 	static const unsigned int timeout = 30;
 	static const char default_exten[] = "s";
 	struct ast_format tmpfmt;
-	struct ast_format_cap *cap_slin = ast_format_cap_alloc();
+	struct ast_format_cap *cap_slin = ast_format_cap_alloc_nolock();
 
 	ast_autoservice_start(chan);
 	if (!cap_slin) {

Modified: team/dvossel/fixtheworld_phase1_step3/apps/app_parkandannounce.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/apps/app_parkandannounce.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/apps/app_parkandannounce.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/apps/app_parkandannounce.c Wed Jan 19 10:32:54 2011
@@ -97,7 +97,7 @@
 	struct outgoing_helper oh = { 0, };
 	int outstate;
 	struct ast_format tmpfmt;
-	struct ast_format_cap *cap_slin = ast_format_cap_alloc();
+	struct ast_format_cap *cap_slin = ast_format_cap_alloc_nolock();
 
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(template);

Modified: team/dvossel/fixtheworld_phase1_step3/apps/app_rpt.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/apps/app_rpt.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/apps/app_rpt.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/apps/app_rpt.c Wed Jan 19 10:32:54 2011
@@ -1073,7 +1073,7 @@
 static struct ast_format_cap *get_slin_cap(struct ast_format_cap *cap)
 {
 	struct ast_format tmp;
-	cap = ast_format_cap_alloc();
+	cap = ast_format_cap_alloc_nolock();
 	if (!cap) {
 		return NULL;
 	}

Modified: team/dvossel/fixtheworld_phase1_step3/bridges/bridge_multiplexed.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/bridges/bridge_multiplexed.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/bridges/bridge_multiplexed.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/bridges/bridge_multiplexed.c Wed Jan 19 10:32:54 2011
@@ -398,7 +398,7 @@
 	if (!(multiplexed_threads = ao2_container_alloc(MULTIPLEXED_BUCKETS, NULL, NULL))) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	if (!(multiplexed_bridge.format_capabilities = ast_format_cap_alloc())) {
+	if (!(multiplexed_bridge.format_capabilities = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
 	ast_format_cap_add_all_by_type(multiplexed_bridge.format_capabilities, AST_FORMAT_TYPE_AUDIO);

Modified: team/dvossel/fixtheworld_phase1_step3/bridges/bridge_simple.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/bridges/bridge_simple.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/bridges/bridge_simple.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/bridges/bridge_simple.c Wed Jan 19 10:32:54 2011
@@ -99,7 +99,7 @@
 
 static int load_module(void)
 {
-	if (!(simple_bridge.format_capabilities = ast_format_cap_alloc())) {
+	if (!(simple_bridge.format_capabilities = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
 	ast_format_cap_add_all_by_type(simple_bridge.format_capabilities, AST_FORMAT_TYPE_AUDIO);

Modified: team/dvossel/fixtheworld_phase1_step3/bridges/bridge_softmix.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/bridges/bridge_softmix.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/bridges/bridge_softmix.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/bridges/bridge_softmix.c Wed Jan 19 10:32:54 2011
@@ -300,7 +300,7 @@
 static int load_module(void)
 {
 	struct ast_format tmp;
-	if (!(softmix_bridge.format_capabilities = ast_format_cap_alloc())) {
+	if (!(softmix_bridge.format_capabilities = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
 #ifdef SOFTMIX_16_SUPPORT

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_agent.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_agent.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_agent.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_agent.c Wed Jan 19 10:32:54 2011
@@ -2437,8 +2437,8 @@
  */
 static int load_module(void)
 {
-	if (!(agent_tech.capabilities = ast_format_cap_alloc())) {
-		ast_log(LOG_ERROR, "ast_format_cap_alloc fail.\n");
+	if (!(agent_tech.capabilities = ast_format_cap_alloc_nolock())) {
+		ast_log(LOG_ERROR, "ast_format_cap_alloc_nolock fail.\n");
 		return AST_MODULE_LOAD_FAILURE;
 	}
 	ast_format_cap_add_all(agent_tech.capabilities);

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_alsa.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_alsa.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_alsa.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_alsa.c Wed Jan 19 10:32:54 2011
@@ -933,7 +933,7 @@
 	struct ast_flags config_flags = { 0 };
 	struct ast_format tmpfmt;
 
-	if (!(alsa_tech.capabilities = ast_format_cap_alloc())) {
+	if (!(alsa_tech.capabilities = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
 	ast_format_cap_add(alsa_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_bridge.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_bridge.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_bridge.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_bridge.c Wed Jan 19 10:32:54 2011
@@ -235,7 +235,7 @@
 /*! \brief Load module into PBX, register channel */
 static int load_module(void)
 {
-	if (!(bridge_tech.capabilities = ast_format_cap_alloc())) {
+	if (!(bridge_tech.capabilities = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_FAILURE;
 	}
 

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_console.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_console.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_console.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_console.c Wed Jan 19 10:32:54 2011
@@ -1470,7 +1470,7 @@
 	struct ast_format tmpfmt;
 	PaError res;
 
-	if (!(console_tech.capabilities = ast_format_cap_alloc())) {
+	if (!(console_tech.capabilities = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
 	ast_format_cap_add(console_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR16, 0));

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_dahdi.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_dahdi.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_dahdi.c Wed Jan 19 10:32:54 2011
@@ -18012,7 +18012,7 @@
 	int y;
 #endif	/* defined(HAVE_PRI) || defined(HAVE_SS7) */
 
-	if (!(dahdi_tech.capabilities = ast_format_cap_alloc())) {
+	if (!(dahdi_tech.capabilities = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_FAILURE;
 	}
 	ast_format_cap_add(dahdi_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_gtalk.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_gtalk.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_gtalk.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_gtalk.c Wed Jan 19 10:32:54 2011
@@ -415,7 +415,7 @@
 	iks_insert_attrib(dcodecs, "xmlns", GOOGLE_AUDIO_NS);
 	iks_insert_attrib(dcodecs, "xml:lang", "en");
 
-	if (!(alreadysent = ast_format_cap_alloc())) {
+	if (!(alreadysent = ast_format_cap_alloc_nolock())) {
 		return 0;
 	}
 	for (x = 0; x < AST_CODEC_PREF_SIZE; x++) {
@@ -1027,9 +1027,9 @@
 	if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
 		return NULL;
 	}
-	tmp->cap = ast_format_cap_alloc();
-	tmp->jointcap = ast_format_cap_alloc();
-	tmp->peercap = ast_format_cap_alloc();
+	tmp->cap = ast_format_cap_alloc_nolock();
+	tmp->jointcap = ast_format_cap_alloc_nolock();
+	tmp->peercap = ast_format_cap_alloc_nolock();
 	if (!tmp->jointcap || !tmp->peercap || !tmp->cap) {
 		tmp->cap = ast_format_cap_destroy(tmp->cap);
 		tmp->jointcap = ast_format_cap_destroy(tmp->jointcap);
@@ -2201,7 +2201,7 @@
 			member = ast_calloc(1, sizeof(*member));
 			ASTOBJ_INIT(member);
 			ASTOBJ_WRLOCK(member);
-			member->cap = ast_format_cap_alloc();
+			member->cap = ast_format_cap_alloc_nolock();
 			if (!strcasecmp(cat, "guest")) {
 				ast_copy_string(member->name, "guest", sizeof(member->name));
 				ast_copy_string(member->user, "guest", sizeof(member->user));
@@ -2267,10 +2267,10 @@
 	char *jabber_loaded = ast_module_helper("", "res_jabber.so", 0, 0, 0, 0);
 	struct ast_format tmpfmt;
 
-	if (!(gtalk_tech.capabilities = ast_format_cap_alloc())) {
+	if (!(gtalk_tech.capabilities = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	if (!(global_capability = ast_format_cap_alloc())) {
+	if (!(global_capability = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
 

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_h323.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_h323.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_h323.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_h323.c Wed Jan 19 10:32:54 2011
@@ -1153,10 +1153,10 @@
 		ast_log(LOG_ERROR, "Couldn't allocate private structure. This is bad\n");
 		return NULL;
 	}
-	pvt->peercap = ast_format_cap_alloc();
-	pvt->jointcap = ast_format_cap_alloc();
-	pvt->nativeformats = ast_format_cap_alloc();
-	pvt->options.cap = ast_format_cap_alloc();
+	pvt->peercap = ast_format_cap_alloc_nolock();
+	pvt->jointcap = ast_format_cap_alloc_nolock();
+	pvt->nativeformats = ast_format_cap_alloc_nolock();
+	pvt->options.cap = ast_format_cap_alloc_nolock();
 	if (!pvt->peercap || !pvt->jointcap || !pvt->options.cap || !pvt->nativeformats) {
 		ast_free(pvt);
 		return NULL;
@@ -1427,7 +1427,7 @@
 		if (!(user = ast_calloc(1, sizeof(*user)))) {
 			return NULL;
 		}
-		if (!(user->options.cap = ast_format_cap_alloc())) {
+		if (!(user->options.cap = ast_format_cap_alloc_nolock())) {
 			ast_free(user);
 			return NULL;
 		}
@@ -1556,7 +1556,7 @@
 		if (!(peer = ast_calloc(1, sizeof(*peer)))) {
 			return NULL;
 		}
-		if (!(peer->options.cap = ast_format_cap_alloc())) {
+		if (!(peer->options.cap = ast_format_cap_alloc_nolock())) {
 			ast_free(peer);
 			return NULL;
 		}
@@ -3338,10 +3338,10 @@
 {
 	int res;
 
-	if (!(oh323_tech.capabilities = ast_format_cap_alloc())) {
+	if (!(oh323_tech.capabilities = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_FAILURE;
 	}
-	if (!(global_options.cap = ast_format_cap_alloc())) {
+	if (!(global_options.cap = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_FAILURE;
 	}
 	ast_format_cap_add_all_by_type(oh323_tech.capabilities, AST_FORMAT_TYPE_AUDIO);

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_iax2.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_iax2.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_iax2.c Wed Jan 19 10:32:54 2011
@@ -1642,7 +1642,7 @@
 	struct ast_format_cap *cap;
 	struct ast_format tmpfmt;
 	iax2_format format = 0;
-	if ((cap = ast_format_cap_alloc())) {
+	if ((cap = ast_format_cap_alloc_nolock())) {
 		ast_format_clear(&tmpfmt);
 		ast_format_cap_from_old_bitfield(cap, formats);
 		ast_codec_choose(pref, cap, find_best, &tmpfmt);
@@ -1655,7 +1655,7 @@
 
 static iax2_format iax2_best_codec(iax2_format formats)
 {
-	struct ast_format_cap *cap = ast_format_cap_alloc();
+	struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
 	struct ast_format tmpfmt;
 	if (!cap) {
 		return 0;
@@ -1680,7 +1680,7 @@
 
 static char *iax2_getformatname_multiple(char *codec_buf, size_t len, iax2_format format)
 {
-	struct ast_format_cap *cap = ast_format_cap_alloc();
+	struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
 
 	if (!cap) {
 		return "(Nothing)";
@@ -1695,7 +1695,7 @@
 static int iax2_parse_allow_disallow(struct ast_codec_pref *pref, iax2_format *formats, const char *list, int allowing)
 {
 	int res;
-	struct ast_format_cap *cap = ast_format_cap_alloc();
+	struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
 	if (!cap) {
 		return 1;
 	}
@@ -1712,7 +1712,7 @@
 static int iax2_data_add_codecs(struct ast_data *root, const char *node_name, iax2_format formats)
 {
 	int res;
-	struct ast_format_cap *cap = ast_format_cap_alloc();
+	struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
 	if (!cap) {
 		return -1;
 	}
@@ -14702,7 +14702,7 @@
 	int x = 0;
 	struct iax2_registry *reg = NULL;
 
-	if (!(iax2_tech.capabilities = ast_format_cap_alloc())) {
+	if (!(iax2_tech.capabilities = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_FAILURE;
 	}
 	ast_format_cap_add_all(iax2_tech.capabilities);

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_jingle.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_jingle.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_jingle.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_jingle.c Wed Jan 19 10:32:54 2011
@@ -302,7 +302,7 @@
 	iks *iq, *jingle, *dcodecs, *payload_red, *payload_audio, *payload_cn;
 	int x;
 	struct ast_format pref_codec;
-	struct ast_format_cap *alreadysent = ast_format_cap_alloc();
+	struct ast_format_cap *alreadysent = ast_format_cap_alloc_nolock();
 
 	if (p->initiator || !alreadysent)
 		return 1;
@@ -775,9 +775,9 @@
 		return NULL;
 	}
 
-	tmp->cap = ast_format_cap_alloc();
-	tmp->jointcap = ast_format_cap_alloc();
-	tmp->peercap = ast_format_cap_alloc();
+	tmp->cap = ast_format_cap_alloc_nolock();
+	tmp->jointcap = ast_format_cap_alloc_nolock();
+	tmp->peercap = ast_format_cap_alloc_nolock();
 	if (!tmp->cap || !tmp->jointcap || !tmp->peercap) {
 		tmp->cap = ast_format_cap_destroy(tmp->cap);
 		tmp->jointcap = ast_format_cap_destroy(tmp->jointcap);
@@ -1846,7 +1846,7 @@
 			member = ast_calloc(1, sizeof(*member));
 			ASTOBJ_INIT(member);
 			ASTOBJ_WRLOCK(member);
-			member->cap = ast_format_cap_alloc();
+			member->cap = ast_format_cap_alloc_nolock();
 			if (!strcasecmp(cat, "guest")) {
 				ast_copy_string(member->name, "guest", sizeof(member->name));
 				ast_copy_string(member->user, "guest", sizeof(member->user));
@@ -1917,12 +1917,12 @@
 
 	char *jabber_loaded = ast_module_helper("", "res_jabber.so", 0, 0, 0, 0);
 
-	if (!(jingle_tech.capabilities = ast_format_cap_alloc())) {
+	if (!(jingle_tech.capabilities = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
 	ast_format_cap_add_all_by_type(jingle_tech.capabilities, AST_FORMAT_TYPE_AUDIO);
-	if (!(global_capability = ast_format_cap_alloc())) {
+	if (!(global_capability = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
 	ast_format_cap_add(global_capability, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0));

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_local.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_local.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_local.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_local.c Wed Jan 19 10:32:54 2011
@@ -1198,7 +1198,7 @@
 /*! \brief Load module into PBX, register channel */
 static int load_module(void)
 {
-	if (!(local_tech.capabilities = ast_format_cap_alloc())) {
+	if (!(local_tech.capabilities = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_FAILURE;
 	}
 	ast_format_cap_add_all(local_tech.capabilities);

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_oss.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_oss.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_oss.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_oss.c Wed Jan 19 10:32:54 2011
@@ -1466,7 +1466,7 @@
 		return AST_MODULE_LOAD_FAILURE;
 	}
 
-	if (!(oss_tech.capabilities = ast_format_cap_alloc())) {
+	if (!(oss_tech.capabilities = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_FAILURE;
 	}
 	ast_format_cap_add(oss_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c Wed Jan 19 10:32:54 2011
@@ -6548,7 +6548,7 @@
 	struct ast_channel *tmp;
 	struct ast_variable *v = NULL;
 	struct ast_format fmt;
-	struct ast_format_cap *what = ast_format_cap_alloc();
+	struct ast_format_cap *what = ast_format_cap_alloc_nolock();
 	struct ast_format_cap *video = NULL;
 	struct ast_format_cap *text = NULL;
 	int needvideo = 0;
@@ -7172,11 +7172,11 @@
 		ao2_t_ref(p, -1, "Yuck, couldn't allocate cc_params struct. Get rid o' p");
 		return NULL;
 	}
-	p->caps = ast_format_cap_alloc();
-	p->jointcaps = ast_format_cap_alloc();
-	p->peercaps = ast_format_cap_alloc();
-	p->redircaps = ast_format_cap_alloc();
-	p->prefcaps = ast_format_cap_alloc();
+	p->caps = ast_format_cap_alloc_nolock();
+	p->jointcaps = ast_format_cap_alloc_nolock();
+	p->peercaps = ast_format_cap_alloc_nolock();
+	p->redircaps = ast_format_cap_alloc_nolock();
+	p->prefcaps = ast_format_cap_alloc_nolock();
 
 	if (!p->caps|| !p->jointcaps || !p->peercaps || !p->redircaps) {
 		p->caps = ast_format_cap_destroy(p->caps);
@@ -8286,15 +8286,15 @@
 	int udptlportno = -1;		/*!< UDPTL Image port number */
 
 	/* Peer capability is the capability in the SDP, non codec is RFC2833 DTMF (101) */	
-	struct ast_format_cap *peercapability = ast_format_cap_alloc();
-	struct ast_format_cap *vpeercapability = ast_format_cap_alloc();
-	struct ast_format_cap *tpeercapability = ast_format_cap_alloc();
+	struct ast_format_cap *peercapability = ast_format_cap_alloc_nolock();
+	struct ast_format_cap *vpeercapability = ast_format_cap_alloc_nolock();
+	struct ast_format_cap *tpeercapability = ast_format_cap_alloc_nolock();
 
 	int peernoncodeccapability = 0, vpeernoncodeccapability = 0, tpeernoncodeccapability = 0;
 
 	struct ast_rtp_codecs newaudiortp, newvideortp, newtextrtp;
-	struct ast_format_cap *newjointcapability = ast_format_cap_alloc(); /* Negotiated capability */
-	struct ast_format_cap *newpeercapability = ast_format_cap_alloc();
+	struct ast_format_cap *newjointcapability = ast_format_cap_alloc_nolock(); /* Negotiated capability */
+	struct ast_format_cap *newpeercapability = ast_format_cap_alloc_nolock();
 	int newnoncodeccapability;
 
 	const char *codecs;
@@ -10688,7 +10688,7 @@
 */
 static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int oldsdp, int add_audio, int add_t38)
 {
-	struct ast_format_cap *alreadysent = ast_format_cap_alloc();
+	struct ast_format_cap *alreadysent = ast_format_cap_alloc_nolock();
 	int res = AST_SUCCESS;
 	struct ast_sockaddr addr = { {0,} };
 	struct ast_sockaddr vaddr = { {0,} };
@@ -26104,7 +26104,7 @@
 		if (!(peer = ao2_t_alloc(sizeof(*peer), sip_destroy_peer_fn, "allocate a peer struct"))) {
 			return NULL;
 		}
-		if (!(peer->caps = ast_format_cap_alloc())) {
+		if (!(peer->caps = ast_format_cap_alloc_nolock())) {
 			ao2_t_ref(peer, -1, "failed to allocate format capabilities, drop peer");
 			return NULL;
 		}
@@ -29041,7 +29041,7 @@
 {
 	ast_verbose("SIP channel loading...\n");
 
-	if (!(sip_tech.capabilities = ast_format_cap_alloc())) {
+	if (!(sip_tech.capabilities = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_FAILURE;
 	}
 	/* the fact that ao2_containers can't resize automatically is a major worry! */
@@ -29053,7 +29053,7 @@
 	dialogs_rtpcheck = ao2_t_container_alloc(HASH_DIALOG_SIZE, dialog_hash_cb, dialog_cmp_cb, "allocate dialogs for rtpchecks");
 	threadt = ao2_t_container_alloc(HASH_DIALOG_SIZE, threadt_hash_cb, threadt_cmp_cb, "allocate threadt table");
 
-	if (!(sip_cfg.caps = ast_format_cap_alloc())) {
+	if (!(sip_cfg.caps = ast_format_cap_alloc_nolock())) {
 		return AST_MODULE_LOAD_FAILURE;
 	}
 	ast_format_cap_add_all_by_type(sip_tech.capabilities, AST_FORMAT_TYPE_AUDIO);

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h Wed Jan 19 10:32:54 2011
@@ -32,6 +32,25 @@
 /*!
  * \brief Allocate a new ast_format_cap structure.
  *
+ * \note Allocation of this object assumes locking
+ * is already occuring and that the point of contention
+ * is above this capabilities structure.  For example,
+ * a tech_pvt object referencing a capabilities structure
+ * can use this function as long as it always holds the
+ * tech_pvt lock while accessing its capabilities.
+ *
+ * \retval ast_format_cap object on success.
+ * \retval NULL on failure.
+ */
+struct ast_format_cap *ast_format_cap_alloc_nolock(void);
+
+/*!
+ * \brief Allocate a new ast_format_cap structure with locking
+ *
+ * \note If no other form of locking is taking place, use this function.
+ * This function makes most sense for globally accessible capabilities structures
+ * that have no other means of locking.
+ *
  * \retval ast_format_cap object on success.
  * \retval NULL on failure.
  */
@@ -83,10 +102,11 @@
 
 /*!
  * \brief create a deep copy of an ast_format_cap structure
- * \retval cap on success
+ *
+ * \retval cap on success, New capabilities structure is allocated with _NO_ locking enabled.
  * \retval NULL on failure
  */
-struct ast_format_cap *ast_format_cap_copy(struct ast_format_cap *cap);
+struct ast_format_cap *ast_format_cap_copy(struct ast_format_cap *src);
 
 /*!
  * \brief determine if a capabilities structure is empty or not
@@ -148,7 +168,12 @@
 /*!
  * \brief Get joint capability structure.
  *
- * \retval !NULL success
+ * \note returns an ast_format_cap object containing the joint capabilities on success.  This new
+ * capabilities structure is allocated with _NO_ locking enabled.  If a joint structure requires
+ * locking, allocate it and use the ast_format_cap_joint_copy function to fill it with the joint
+ * capabilities.
+ *
+ * \retval !NULL success, joint capabilties structure with _NO_ locking enabled.
  * \retval NULL failure
  */
 struct ast_format_cap *ast_format_cap_joint(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2);
@@ -173,7 +198,7 @@
 /*!
  * \brief Get all capabilities for a specific media type
  *
- * \retval !NULL success
+ * \retval !NULL success, new capabilities structure with _NO_ locking enabled on the new structure.
  * \retval NULL failure
  */
 struct ast_format_cap *ast_format_cap_get_type(struct ast_format_cap *cap, enum ast_format_type ftype);

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/rtp_engine.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/rtp_engine.h?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/rtp_engine.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/rtp_engine.h Wed Jan 19 10:32:54 2011
@@ -1070,7 +1070,7 @@
  * Example usage:
  *
  * \code
- * struct ast_format_cap *astformats = ast_format_cap_alloc()
+ * struct ast_format_cap *astformats = ast_format_cap_alloc_nolock()
  * int nonastformats;
  * ast_rtp_codecs_payload_Formats(&codecs, &astformats, &nonastformats);
  * \endcode
@@ -1144,7 +1144,7 @@
  * \code
  * char buf[256] = "";
  * struct ast_format tmp_fmt;
- * struct ast_format_cap *cap = ast_format_cap_alloc();
+ * struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
  * ast_format_cap_add(cap, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0));
  * ast_format_cap_add(cap, ast_format_set(&tmp_fmt, AST_FORMAT_GSM, 0));
  * char *mime = ast_rtp_lookup_mime_multiple2(&buf, sizeof(buf), cap, 0, 1, 0);

Modified: team/dvossel/fixtheworld_phase1_step3/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/ccss.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/ccss.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/ccss.c Wed Jan 19 10:32:54 2011
@@ -2483,7 +2483,7 @@
 	const char *callback_macro = ast_get_cc_callback_macro(agent->cc_params);
 	unsigned int recall_timer = ast_get_cc_recall_timer(agent->cc_params) * 1000;
 	struct ast_format tmp_fmt;
-	struct ast_format_cap *tmp_cap = ast_format_cap_alloc();
+	struct ast_format_cap *tmp_cap = ast_format_cap_alloc_nolock();
 
 	if (!tmp_cap) {
 		return NULL;

Modified: team/dvossel/fixtheworld_phase1_step3/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/channel.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/channel.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/channel.c Wed Jan 19 10:32:54 2011
@@ -1086,7 +1086,7 @@
 		/* Channel structure allocation failure. */
 		return NULL;
 	}
-	if (!(tmp->nativeformats = ast_format_cap_alloc())) {
+	if (!(tmp->nativeformats = ast_format_cap_alloc_nolock())) {
 		ao2_ref(tmp, -1);
 		/* format capabilities structure allocation failure */
 		return NULL;
@@ -5049,7 +5049,7 @@
 
 int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
 {
-	struct ast_format_cap *cap = ast_format_cap_alloc();
+	struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
 	int res;
 	if (!cap) {
 		return -1;
@@ -5069,7 +5069,7 @@
 
 int ast_set_read_format_by_id(struct ast_channel *chan, enum ast_format_id id)
 {
-	struct ast_format_cap *cap = ast_format_cap_alloc();
+	struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
 	struct ast_format tmp_format;
 	int res;
 	if (!cap) {
@@ -5100,7 +5100,7 @@
 
 int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
 {
-	struct ast_format_cap *cap = ast_format_cap_alloc();
+	struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
 	int res;
 	if (!cap) {
 		return -1;
@@ -5120,7 +5120,7 @@
 
 int ast_set_write_format_by_id(struct ast_channel *chan, enum ast_format_id id)
 {
-	struct ast_format_cap *cap = ast_format_cap_alloc();
+	struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
 	struct ast_format tmp_format;
 	int res;
 	if (!cap) {

Modified: team/dvossel/fixtheworld_phase1_step3/main/dial.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/dial.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/dial.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/dial.c Wed Jan 19 10:32:54 2011
@@ -257,7 +257,7 @@
 	if (chan) {
 		cap_request = chan->nativeformats;
 	} else {
-		cap_all_audio = ast_format_cap_alloc();
+		cap_all_audio = ast_format_cap_alloc_nolock();
 		ast_format_cap_add_all_by_type(cap_all_audio, AST_FORMAT_TYPE_AUDIO);
 		cap_request = cap_all_audio;
 	}

Modified: team/dvossel/fixtheworld_phase1_step3/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/features.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/features.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/features.c Wed Jan 19 10:32:54 2011
@@ -2772,7 +2772,7 @@
 	struct ast_format_cap *tmp_cap;
 	struct ast_format best_audio_fmt;
 
-	tmp_cap = ast_format_cap_alloc();
+	tmp_cap = ast_format_cap_alloc_nolock();
 	if (!tmp_cap) {
 		return NULL;
 	}

Modified: team/dvossel/fixtheworld_phase1_step3/main/file.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/file.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/file.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/file.c Wed Jan 19 10:32:54 2011
@@ -665,7 +665,7 @@
 	if (buf == NULL)
 		return NULL;
 
-	if (!(file_fmt_cap = ast_format_cap_alloc())) {
+	if (!(file_fmt_cap = ast_format_cap_alloc_nolock())) {
 		return NULL;
 	}
 	if (!fileexists_core(filename, NULL, preflang, buf, buflen, file_fmt_cap) ||
@@ -715,7 +715,7 @@
 	if (!ast_format_cap_has_type(chan->nativeformats, AST_FORMAT_TYPE_VIDEO)) {
 		return NULL;
 	}
-	if (!(tmp_cap = ast_format_cap_alloc())) {
+	if (!(tmp_cap = ast_format_cap_alloc_nolock())) {
 		return NULL;
 	}
 	/* Video is supported, so see what video formats exist for this file */

Modified: team/dvossel/fixtheworld_phase1_step3/main/format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/format_cap.c?view=diff&rev=302459&r1=302458&r2=302459
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/format_cap.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/format_cap.c Wed Jan 19 10:32:54 2011
@@ -40,6 +40,7 @@
 	/* The capabilities structure is just an ao2 container of ast_formats */
 	struct ao2_container *formats;
 	struct ao2_iterator it;
+	int nolock;
 };
 
 /*! format exists within capabilities structure if it is identical to
@@ -62,14 +63,14 @@
 	return format->id;
 }
 
-struct ast_format_cap *ast_format_cap_alloc(void)
+static struct ast_format_cap *cap_alloc_helper(int nolock)
 {
 	struct ast_format_cap *cap = ast_calloc(1, sizeof(*cap));
 
 	if (!cap) {
 		return NULL;
 	}
-
+	cap->nolock = nolock ? OBJ_NOLOCK : 0;
 	if (!(cap->formats = ao2_container_alloc(256, hash_cb, cmp_cb))) {
 		ast_free(cap);
 		return NULL;
@@ -78,6 +79,16 @@
 	return cap;
 }
 
+struct ast_format_cap *ast_format_cap_alloc_nolock(void)
+{
+	return cap_alloc_helper(1);
+}
+
+struct ast_format_cap *ast_format_cap_alloc(void)
+{
+	return cap_alloc_helper(0);
+}
+
 void *ast_format_cap_destroy(struct ast_format_cap *cap)
 {
 	if (!cap) {
@@ -99,7 +110,11 @@
 		return;
 	}
 	ast_format_copy(fnew, format);
-	ao2_link_nolock(cap->formats, fnew);
+	if (cap->nolock) {
+		ao2_link_nolock(cap->formats, fnew);
+	} else {
+		ao2_link(cap->formats, fnew);
+	}
 	ao2_ref(fnew, -1);
 }
 
@@ -143,7 +158,7 @@
 
 void ast_format_cap_append(struct ast_format_cap *dst, const struct ast_format_cap *src)
 {
-	ao2_callback(src->formats, OBJ_NODATA | OBJ_NOLOCK, append_cb, dst);
+	ao2_callback(src->formats, OBJ_NODATA | src->nolock, append_cb, dst);
 }
 
 static int copy_cb(void *obj, void *arg, int flag)
@@ -158,16 +173,16 @@
 void ast_format_cap_copy2(struct ast_format_cap *dst, const struct ast_format_cap *src)
 {
 	ast_format_cap_remove_all(dst);
-	ao2_callback(src->formats, OBJ_NODATA | OBJ_NOLOCK, copy_cb, dst);
+	ao2_callback(src->formats, OBJ_NODATA | src->nolock, copy_cb, dst);
 }
 
 struct ast_format_cap *ast_format_cap_copy(struct ast_format_cap *cap)
 {
-	struct ast_format_cap *dst = ast_format_cap_alloc();
+	struct ast_format_cap *dst = ast_format_cap_alloc_nolock();
 	if (!dst) {
 		return NULL;
 	}
-	ao2_callback(cap->formats, OBJ_NODATA | OBJ_NOLOCK, copy_cb, dst);
+	ao2_callback(cap->formats, OBJ_NODATA | cap->nolock, copy_cb, dst);
 	return dst;
 }
 
@@ -190,7 +205,7 @@
 int ast_format_cap_remove(struct ast_format_cap *cap, struct ast_format *format)
 {
 	struct ast_format *fremove;
-	fremove = ao2_callback(cap->formats, OBJ_POINTER | OBJ_UNLINK | OBJ_NOLOCK, find_exact_cb, format);
+	fremove = ao2_callback(cap->formats, OBJ_POINTER | OBJ_UNLINK | cap->nolock, find_exact_cb, format);
 
 	if (fremove) {
 		ao2_ref(fremove, -1);
@@ -230,7 +245,7 @@
 	};
 
 	ao2_callback(cap->formats,
-		OBJ_NODATA | OBJ_NOLOCK | OBJ_MULTIPLE | OBJ_UNLINK,
+		OBJ_NODATA | cap->nolock | OBJ_MULTIPLE | OBJ_UNLINK,
 		multiple_by_id_cb,
 		&data);
 
@@ -249,10 +264,10 @@
 	struct ao2_iterator it;
 	struct ast_format *tmp;
 
-	it = ao2_iterator_init(cap->formats, AO2_ITERATOR_DONTLOCK);
+	it = ao2_iterator_init(cap->formats, cap->nolock ? AO2_ITERATOR_DONTLOCK : 0);
 	while ((tmp = ao2_iterator_next(&it))) {
 		if (AST_FORMAT_GET_TYPE(tmp->id) == type) {
-			ao2_callback(cap->formats, OBJ_UNLINK | OBJ_POINTER | OBJ_NODATA | OBJ_NOLOCK, cmp_cb, tmp);
+			ao2_callback(cap->formats, OBJ_UNLINK | OBJ_POINTER | OBJ_NODATA | cap->nolock, cmp_cb, tmp);
 		}
 		ao2_ref(tmp, -1);
 	}
@@ -261,14 +276,14 @@
 
 void ast_format_cap_remove_all(struct ast_format_cap *cap)
 {
-	ao2_callback(cap->formats, OBJ_NODATA | OBJ_NOLOCK | OBJ_MULTIPLE | OBJ_UNLINK, NULL, NULL);

[... 568 lines stripped ...]



More information about the asterisk-commits mailing list