Index: udptl.c =================================================================== --- udptl.c (revision 23334) +++ 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 23334) +++ 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 23334) +++ 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 23334) +++ 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 23334) +++ 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 23334) +++ 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: res/res_monitor.c =================================================================== --- res/res_monitor.c (revision 23334) +++ res/res_monitor.c (working copy) @@ -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; @@ -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_agi.c =================================================================== --- res/res_agi.c (revision 23334) +++ 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 23334) +++ 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/snmp/agent.c =================================================================== --- res/snmp/agent.c (revision 23334) +++ res/snmp/agent.c (working copy) @@ -216,7 +216,7 @@ for (chan = ast_channel_walk_locked(NULL); chan && i; chan = ast_channel_walk_locked(chan), i--) - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); if (chan == NULL) return NULL; *var_len = sizeof(long_ret); @@ -513,7 +513,7 @@ ret = NULL; break; } - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); return ret; } @@ -583,7 +583,7 @@ case ASTCHANTYPECHANNELS: long_ret = 0; for (chan = ast_channel_walk_locked(NULL); chan; chan = ast_channel_walk_locked(chan)) { - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); if (chan->tech == tech) long_ret++; }