Index: udptl.c =================================================================== --- udptl.c (revision 23304) +++ udptl.c (working copy) @@ -996,24 +996,24 @@ void *pvt1; int to; - ast_mutex_lock(&c0->lock); - while (ast_mutex_trylock(&c1->lock)) { - ast_mutex_unlock(&c0->lock); + ast_channel_lock(c0); + while (ast_channel_trylock(c1)) { + ast_channel_unlock(c0); usleep(1); - ast_mutex_lock(&c0->lock); + ast_channel_lock(c0); } pr0 = get_proto(c0); pr1 = get_proto(c1); if (!pr0) { ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c0->name); - ast_mutex_unlock(&c0->lock); - ast_mutex_unlock(&c1->lock); + ast_channel_unlock(c0); + ast_channel_unlock(c1); return -1; } if (!pr1) { ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c1->name); - ast_mutex_unlock(&c0->lock); - ast_mutex_unlock(&c1->lock); + ast_channel_unlock(c0); + ast_channel_unlock(c1); return -1; } pvt0 = c0->tech_pvt; @@ -1022,8 +1022,8 @@ p1 = pr1->get_udptl_info(c1); if (!p0 || !p1) { /* Somebody doesn't want to play... */ - ast_mutex_unlock(&c0->lock); - ast_mutex_unlock(&c1->lock); + ast_channel_unlock(c0); + ast_channel_unlock(c1); return -2; } if (pr0->set_udptl_peer(c0, p1)) { @@ -1038,8 +1038,8 @@ /* Store UDPTL peer */ ast_udptl_get_peer(p0, &ac0); } - ast_mutex_unlock(&c0->lock); - ast_mutex_unlock(&c1->lock); + ast_channel_unlock(c0); + ast_channel_unlock(c1); cs[0] = c0; cs[1] = c1; cs[2] = NULL; Index: pbx.c =================================================================== --- pbx.c (revision 23304) +++ pbx.c (working copy) @@ -4147,7 +4147,7 @@ { int res = 0; - ast_mutex_lock(&chan->lock); + ast_channel_lock(chan); if (chan->pbx) { /* This channel is currently in the PBX */ @@ -4174,9 +4174,9 @@ ast_channel_masquerade(tmpchan, chan); /* Grab the locks and get going */ - ast_mutex_lock(&tmpchan->lock); + ast_channel_lock(tmpchan); ast_do_masquerade(tmpchan); - ast_mutex_unlock(&tmpchan->lock); + ast_channel_unlock(tmpchan); /* Start the PBX going on our stolen channel */ if (ast_pbx_start(tmpchan)) { ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmpchan->name); @@ -4185,7 +4185,7 @@ } } } - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); return res; } @@ -4197,7 +4197,7 @@ chan = ast_get_channel_by_name_locked(channame); if (chan) { res = ast_async_goto(chan, context, exten, priority); - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); } return res; } @@ -4576,7 +4576,7 @@ if (channel) { *channel = chan; if (chan) - ast_mutex_lock(&chan->lock); + ast_channel_lock(chan); } if (chan) { if (chan->cdr) { /* check if the channel already has a cdr record, if not give it one */ @@ -4600,7 +4600,7 @@ if (sync > 1) { if (channel) - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); if (ast_pbx_run(chan)) { ast_log(LOG_ERROR, "Unable to run PBX on %s\n", chan->name); if (channel) @@ -4613,7 +4613,7 @@ ast_log(LOG_ERROR, "Unable to start PBX on %s\n", chan->name); if (channel) { *channel = NULL; - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); } ast_hangup(chan); res = -1; @@ -4632,7 +4632,7 @@ if (channel) { *channel = NULL; - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); } ast_hangup(chan); } @@ -4673,7 +4673,7 @@ if (channel) { *channel = chan; if (chan) - ast_mutex_lock(&chan->lock); + ast_channel_lock(chan); } if (!chan) { free(as); @@ -4694,7 +4694,7 @@ free(as); if (channel) { *channel = NULL; - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); } ast_hangup(chan); res = -1; @@ -4783,18 +4783,18 @@ tmp->chan = chan; if (sync > 1) { if (locked_channel) - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); ast_pbx_run_app(tmp); } else { pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if (locked_channel) - ast_mutex_lock(&chan->lock); + ast_channel_lock(chan); if (ast_pthread_create(&tmp->t, &attr, ast_pbx_run_app, tmp)) { ast_log(LOG_WARNING, "Unable to spawn execute thread on %s: %s\n", chan->name, strerror(errno)); free(tmp); if (locked_channel) - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); ast_hangup(chan); res = -1; } else { @@ -4851,12 +4851,12 @@ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if (locked_channel) - ast_mutex_lock(&chan->lock); + ast_channel_lock(chan); if (ast_pthread_create(&as->p, &attr, async_wait, as)) { ast_log(LOG_WARNING, "Failed to start async wait\n"); free(as); if (locked_channel) - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); ast_hangup(chan); res = -1; goto outgoing_app_cleanup; @@ -5505,7 +5505,7 @@ sprintf(s, "${%s}", value); pbx_substitute_variables_helper(chan2, s, tmp, sizeof(tmp) - 1); } - ast_mutex_unlock(&chan2->lock); + ast_channel_unlock(chan2); } pbx_builtin_setvar_helper(chan, name, tmp); } Index: manager.c =================================================================== --- manager.c (revision 23304) +++ manager.c (working copy) @@ -1053,7 +1053,7 @@ return 0; } ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT); - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); astman_send_ack(s, m, "Channel Hungup"); return 0; } @@ -1093,7 +1093,7 @@ pbx_builtin_setvar_helper(c, varname, varval); if (c) - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); astman_send_ack(s, m, "Variable Set"); @@ -1136,7 +1136,7 @@ } if (c) - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); astman_append(s, "Response: Success\r\n" "Variable: %s\r\nValue: %s\r\n", varname, varval); if (!ast_strlen_zero(id)) @@ -1227,7 +1227,7 @@ c->accountcode, ast_state2str(c->_state), bridge, c->uniqueid, idText); } - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); if (!all) break; c = ast_channel_walk_locked(c); @@ -1297,9 +1297,9 @@ } else astman_send_error(s, m, "Redirect failed"); if (chan) - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); if (chan2) - ast_mutex_unlock(&chan2->lock); + ast_channel_unlock(chan2); return 0; } @@ -1363,7 +1363,7 @@ /* Locked by ast_pbx_outgoing_exten or ast_pbx_outgoing_app */ if (chan) - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); free(in); return NULL; } @@ -1626,7 +1626,7 @@ return 0; } ast_channel_setwhentohangup(c, timeout); - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); astman_send_ack(s, m, "Timeout Set"); return 0; } Index: devicestate.c =================================================================== --- devicestate.c (revision 23304) +++ devicestate.c (working copy) @@ -101,7 +101,7 @@ else res = AST_DEVICE_INUSE; - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); return res; } Index: cli.c =================================================================== --- cli.c (revision 23304) +++ cli.c (working copy) @@ -444,7 +444,7 @@ ast_cli(fd, FORMAT_STRING, c->name, locbuf, ast_state2str(c->_state), appdata); } numchans++; - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); } if (!concise) { ast_cli(fd, "%d active channel%s\n", numchans, ESS(numchans)); @@ -505,7 +505,7 @@ if (c) { ast_cli(fd, "Requested Hangup on channel '%s'\n", c->name); ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT); - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); } else ast_cli(fd, "%s is not a known channel\n", argv[2]); return RESULT_SUCCESS; @@ -630,7 +630,7 @@ c->fout |= DEBUGCHAN_FLAG; ast_cli(fd, "Debugging enabled on channel %s\n", c->name); } - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); if (!is_all) break; c = ast_channel_walk_locked(c); @@ -662,7 +662,7 @@ c->fout &= ~DEBUGCHAN_FLAG; ast_cli(fd, "Debugging disabled on channel %s\n", c->name); } - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); if (!is_all) break; c = ast_channel_walk_locked(c); @@ -747,7 +747,7 @@ if(c->cdr && ast_cdr_serialize_variables(c->cdr,buf, sizeof(buf), '=', '\n', 1)) ast_cli(fd," CDR Variables:\n%s\n",buf); - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); return RESULT_SUCCESS; } @@ -790,7 +790,7 @@ while (ret == ¬found && (c = ast_channel_walk_locked(c))) { if (!strncasecmp(word, c->name, wordlen) && ++which > state) ret = ast_strdup(c->name); - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); } return ret == ¬found ? NULL : ret; } @@ -874,7 +874,7 @@ } } numchans++; - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); } if (havepattern) Index: app.c =================================================================== --- app.c (revision 23304) +++ app.c (working copy) @@ -1042,7 +1042,7 @@ test = pbx_builtin_getvar_helper(chan, cat); if (test && !strcasecmp(test, group)) count++; - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); } return count; @@ -1072,7 +1072,7 @@ test = pbx_builtin_getvar_helper(chan, cat); if (test && !regexec(®exbuf, test, 0, NULL, 0)) count++; - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); } regfree(®exbuf); Index: apps/app_chanspy.c =================================================================== --- apps/app_chanspy.c (revision 23304) +++ apps/app_chanspy.c (working copy) @@ -198,9 +198,9 @@ ast_log(LOG_NOTICE, "Attaching %s to %s\n", spychan->name, chan->name); - ast_mutex_lock(&chan->lock); + ast_channel_lock(chan); res = ast_channel_spy_add(chan, spy); - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); if (!res && ast_test_flag(chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan))) { ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE); @@ -219,9 +219,9 @@ if (!chan) return; - ast_mutex_lock(&chan->lock); + ast_channel_lock(chan); ast_channel_spy_remove(chan, spy); - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); }; /* Map 'volume' levels from -4 through +4 into Index: apps/app_mixmonitor.c =================================================================== --- apps/app_mixmonitor.c (revision 23304) +++ apps/app_mixmonitor.c (working copy) @@ -133,9 +133,9 @@ if (!chan) return; - ast_mutex_lock(&chan->lock); + ast_channel_lock(chan); ast_channel_spy_remove(chan, spy); - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); } static int startmon(struct ast_channel *chan, struct ast_channel_spy *spy) @@ -146,9 +146,9 @@ if (!chan) return -1; - ast_mutex_lock(&chan->lock); + ast_channel_lock(chan); res = ast_channel_spy_add(chan, spy); - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); if (!res && ast_test_flag(chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan))) ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE); @@ -410,9 +410,9 @@ LOCAL_USER_ADD(u); - if (!ast_mutex_lock(&chan->lock)) { + if (!ast_channel_lock(chan)) { ast_channel_spy_stop_by_type(chan, mixmonitor_spy_type); - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); } else { ast_log(LOG_WARNING, "Could not lock %s to stop MixMonitor on it\n", chan->name); @@ -440,7 +440,7 @@ else if (!strcasecmp(argv[1], "stop")) ast_channel_spy_stop_by_type(chan, mixmonitor_spy_type); - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); return RESULT_SUCCESS; } Index: apps/app_sendtext.c =================================================================== --- apps/app_sendtext.c (revision 23304) +++ apps/app_sendtext.c (working copy) @@ -97,9 +97,9 @@ priority_jump = 1; } - ast_mutex_lock(&chan->lock); + ast_channel_lock(chan); if (!chan->tech->send_text) { - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); /* Does not support transport */ if (priority_jump || ast_opt_priority_jumping) ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); @@ -107,7 +107,7 @@ return 0; } status = "FAILURE"; - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); res = ast_sendtext(chan, args.text); if (!res) status = "SUCCESS"; Index: funcs/func_channel.c =================================================================== --- funcs/func_channel.c (revision 23304) +++ funcs/func_channel.c (working copy) @@ -39,15 +39,15 @@ #include "asterisk/stringfields.h" #define locked_copy_string(chan, dest, source, len) \ do { \ - ast_mutex_lock(&chan->lock); \ + ast_channel_lock(chan); \ ast_copy_string(dest, source, len); \ - ast_mutex_unlock(&chan->lock); \ + ast_channel_unlock(chan); \ } while (0) #define locked_string_field_set(chan, field, source) \ do { \ - ast_mutex_lock(&chan->lock); \ + ast_channel_lock(chan); \ ast_string_field_set(chan, field, source); \ - ast_mutex_unlock(&chan->lock); \ + ast_channel_unlock(chan); \ } while (0) static int func_channel_read(struct ast_channel *chan, char *function, Index: res/res_agi.c =================================================================== --- res/res_agi.c (revision 23304) +++ res/res_agi.c (working copy) @@ -1025,7 +1025,7 @@ /* we have a matching channel */ ast_softhangup(c,AST_SOFTHANGUP_EXPLICIT); fdprintf(agi->fd, "200 result=1\n"); - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); return RESULT_SUCCESS; } /* if we get this far no channel name matched the argument given */ @@ -1093,7 +1093,7 @@ c = ast_get_channel_by_name_locked(argv[2]); if (c) { fdprintf(agi->fd, "200 result=%d\n", c->_state); - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); return RESULT_SUCCESS; } /* if we get this far no channel name matched the argument given */ @@ -1155,7 +1155,7 @@ fdprintf(agi->fd, "200 result=0\n"); } if (chan2 && (chan2 != chan)) - ast_mutex_unlock(&chan2->lock); + ast_channel_unlock(chan2); return RESULT_SUCCESS; } Index: res/res_features.c =================================================================== --- res/res_features.c (revision 23304) +++ res/res_features.c (working copy) @@ -1859,7 +1859,7 @@ if (!ch2) { snprintf(buf, sizeof(buf), "Channel does not exist: %s", channel2); astman_send_error(s, m, buf); - ast_mutex_unlock(&ch1->lock); + ast_channel_unlock(ch1); return 0; } @@ -1875,8 +1875,8 @@ astman_send_error(s, m, "Park failure"); } - ast_mutex_unlock(&ch1->lock); - ast_mutex_unlock(&ch2->lock); + ast_channel_unlock(ch1); + ast_channel_unlock(ch2); return 0; } @@ -1895,7 +1895,7 @@ (cur->_state == AST_STATE_RING))) { break; } - ast_mutex_unlock(&cur->lock); + ast_channel_unlock(cur); } if (cur) { if (option_debug) @@ -1909,7 +1909,7 @@ res = ast_channel_masquerade(cur, chan); if (res) ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan->name, cur->name); /* Done */ - ast_mutex_unlock(&cur->lock); + ast_channel_unlock(cur); } else { if (option_debug) ast_log(LOG_DEBUG, "No call pickup possible...\n"); Index: res/res_monitor.c =================================================================== --- res/res_monitor.c (revision 23304) +++ res/res_monitor.c (working copy) @@ -119,13 +119,13 @@ static int ast_monitor_set_state(struct ast_channel *chan, int state) { - LOCK_IF_NEEDED(&chan->lock, 1); + LOCK_IF_NEEDED(&chan->_lock, 1); if (!chan->monitor) { - UNLOCK_IF_NEEDED(&chan->lock, 1); + UNLOCK_IF_NEEDED(&chan->_lock, 1); return -1; } chan->monitor->state = state; - UNLOCK_IF_NEEDED(&chan->lock, 1); + UNLOCK_IF_NEEDED(&chan->_lock, 1); return 0; } @@ -136,7 +136,7 @@ int res = 0; char tmp[256]; - LOCK_IF_NEEDED(&chan->lock, need_lock); + LOCK_IF_NEEDED(&chan->_lock, need_lock); if (!(chan->monitor)) { struct ast_channel_monitor *monitor; @@ -151,7 +151,7 @@ } if (!(monitor = ast_calloc(1, sizeof(*monitor)))) { - UNLOCK_IF_NEEDED(&chan->lock, need_lock); + UNLOCK_IF_NEEDED(&chan->_lock, need_lock); return -1; } @@ -211,7 +211,7 @@ ast_log(LOG_WARNING, "Could not create file %s\n", monitor->read_filename); free(monitor); - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); return -1; } if (ast_fileexists(monitor->write_filename, NULL, NULL) > 0) { @@ -224,7 +224,7 @@ monitor->write_filename); ast_closestream(monitor->read_stream); free(monitor); - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); return -1; } chan->monitor = monitor; @@ -237,7 +237,7 @@ res = -1; } - UNLOCK_IF_NEEDED(&chan->lock, need_lock); + UNLOCK_IF_NEEDED(&chan->_lock, need_lock); return res; } @@ -247,7 +247,7 @@ { int delfiles = 0; - LOCK_IF_NEEDED(&chan->lock, need_lock); + LOCK_IF_NEEDED(&chan->_lock, need_lock); if (chan->monitor) { char filename[ FILENAME_MAX ]; @@ -316,7 +316,7 @@ chan->monitor = NULL; } - UNLOCK_IF_NEEDED(&chan->lock, need_lock); + UNLOCK_IF_NEEDED(&chan->_lock, need_lock); return 0; } @@ -353,7 +353,7 @@ return -1; } - LOCK_IF_NEEDED(&chan->lock, need_lock); + LOCK_IF_NEEDED(&chan->_lock, need_lock); if (chan->monitor) { int directory = strchr(fname_base, '/') ? 1 : 0; @@ -370,7 +370,7 @@ ast_log(LOG_WARNING, "Cannot change monitor filename of channel %s to %s, monitoring not started\n", chan->name, fname_base); } - UNLOCK_IF_NEEDED(&chan->lock, need_lock); + UNLOCK_IF_NEEDED(&chan->_lock, need_lock); return 0; } @@ -492,7 +492,7 @@ /* No filename base specified, default to channel name as per CLI */ if (!(fname = ast_strdup(c->name))) { astman_send_error(s, m, "Could not start monitoring channel"); - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); return 0; } /* Channels have the format technology/channel_name - have to replace that / */ @@ -503,7 +503,7 @@ if (ast_monitor_start(c, format, fname, 1)) { if (ast_monitor_change_fname(c, fname, 1)) { astman_send_error(s, m, "Could not start monitoring channel"); - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); return 0; } } @@ -512,7 +512,7 @@ ast_monitor_setjoinfiles(c, 1); } - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); astman_send_ack(s, m, "Started monitoring channel"); return 0; } @@ -537,7 +537,7 @@ return 0; } res = ast_monitor_stop(c, 1); - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); if (res) { astman_send_error(s, m, "Could not stop monitoring channel"); return 0; @@ -574,10 +574,10 @@ } if (ast_monitor_change_fname(c, fname, 1)) { astman_send_error(s, m, "Could not change monitored filename of channel"); - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); return 0; } - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); astman_send_ack(s, m, "Changed monitor filename"); return 0; } @@ -617,7 +617,7 @@ else ast_monitor_unpause(c); - ast_mutex_unlock(&c->lock); + ast_channel_unlock(c); astman_send_ack(s, m, "Paused monitoring of the channel"); return 0; } Index: res/res_musiconhold.c =================================================================== --- res/res_musiconhold.c (revision 23304) +++ res/res_musiconhold.c (working copy) @@ -1108,7 +1108,7 @@ else ast_deactivate_generator(chan); } - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); } }