test = pbx_builtin_getvar_helper(chan, cat);
if (test && !strcasecmp(test, group))
count++;
- ast_mutex_unlock(&chan->lock);
+ ast_channel_unlock(chan);
}
return count;
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);
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));
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;
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);
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);
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;
}
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;
}
}
}
numchans++;
- ast_mutex_unlock(&c->lock);
+ ast_channel_unlock(c);
}
if (havepattern)
else
res = AST_DEVICE_INUSE;
- ast_mutex_unlock(&chan->lock);
+ ast_channel_unlock(chan);
return res;
}
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;
}
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");
}
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))
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);
} 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;
}
/* 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;
}
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;
}
{
int res = 0;
- ast_mutex_lock(&chan->lock);
+ ast_channel_lock(chan);
if (chan->pbx) {
/* This channel is currently in the PBX */
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);
}
}
}
- ast_mutex_unlock(&chan->lock);
+ ast_channel_unlock(chan);
return res;
}
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;
}
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 */
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)
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;
if (channel) {
*channel = NULL;
- ast_mutex_unlock(&chan->lock);
+ ast_channel_unlock(chan);
}
ast_hangup(chan);
}
if (channel) {
*channel = chan;
if (chan)
- ast_mutex_lock(&chan->lock);
+ ast_channel_lock(chan);
}
if (!chan) {
free(as);
free(as);
if (channel) {
*channel = NULL;
- ast_mutex_unlock(&chan->lock);
+ ast_channel_unlock(chan);
}
ast_hangup(chan);
res = -1;
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 {
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;
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);
}
/* 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 */
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 */
fdprintf(agi->fd, "200 result=0\n");
}
if (chan2 && (chan2 != chan))
- ast_mutex_unlock(&chan2->lock);
+ ast_channel_unlock(chan2);
return RESULT_SUCCESS;
}
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;
}
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;
}
(cur->_state == AST_STATE_RING))) {
break;
}
- ast_mutex_unlock(&cur->lock);
+ ast_channel_unlock(cur);
}
if (cur) {
if (option_debug)
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");
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) {
monitor->write_filename);
ast_closestream(monitor->read_stream);
free(monitor);
- ast_mutex_unlock(&chan->lock);
+ ast_channel_unlock(chan);
return -1;
}
chan->monitor = monitor;
/* 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 / */
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;
}
}
ast_monitor_setjoinfiles(c, 1);
}
- ast_mutex_unlock(&c->lock);
+ ast_channel_unlock(c);
astman_send_ack(s, m, "Started monitoring channel");
return 0;
}
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;
}
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;
}
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;
}
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);
ret = NULL;
break;
}
- ast_mutex_unlock(&chan->lock);
+ ast_channel_unlock(chan);
return ret;
}
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++;
}
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;
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)) {
/* 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;