[asterisk-commits] trunk r23355 - in /trunk: ./ res/ res/snmp/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sat Apr 29 07:50:19 MST 2006
Author: russell
Date: Sat Apr 29 09:50:18 2006
New Revision: 23355
URL: http://svn.digium.com/view/asterisk?rev=23355&view=rev
Log:
a bunch of conversion to ast_channel_*lock (issue #7058)
Modified:
trunk/app.c
trunk/cli.c
trunk/devicestate.c
trunk/manager.c
trunk/pbx.c
trunk/res/res_agi.c
trunk/res/res_features.c
trunk/res/res_monitor.c
trunk/res/snmp/agent.c
trunk/udptl.c
Modified: trunk/app.c
URL: http://svn.digium.com/view/asterisk/trunk/app.c?rev=23355&r1=23354&r2=23355&view=diff
==============================================================================
--- trunk/app.c (original)
+++ trunk/app.c Sat Apr 29 09:50:18 2006
@@ -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);
Modified: trunk/cli.c
URL: http://svn.digium.com/view/asterisk/trunk/cli.c?rev=23355&r1=23354&r2=23355&view=diff
==============================================================================
--- trunk/cli.c (original)
+++ trunk/cli.c Sat Apr 29 09:50:18 2006
@@ -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)
Modified: trunk/devicestate.c
URL: http://svn.digium.com/view/asterisk/trunk/devicestate.c?rev=23355&r1=23354&r2=23355&view=diff
==============================================================================
--- trunk/devicestate.c (original)
+++ trunk/devicestate.c Sat Apr 29 09:50:18 2006
@@ -101,7 +101,7 @@
else
res = AST_DEVICE_INUSE;
- ast_mutex_unlock(&chan->lock);
+ ast_channel_unlock(chan);
return res;
}
Modified: trunk/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/manager.c?rev=23355&r1=23354&r2=23355&view=diff
==============================================================================
--- trunk/manager.c (original)
+++ trunk/manager.c Sat Apr 29 09:50:18 2006
@@ -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;
}
Modified: trunk/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx.c?rev=23355&r1=23354&r2=23355&view=diff
==============================================================================
--- trunk/pbx.c (original)
+++ trunk/pbx.c Sat Apr 29 09:50:18 2006
@@ -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);
}
Modified: trunk/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_agi.c?rev=23355&r1=23354&r2=23355&view=diff
==============================================================================
--- trunk/res/res_agi.c (original)
+++ trunk/res/res_agi.c Sat Apr 29 09:50:18 2006
@@ -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;
}
Modified: trunk/res/res_features.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_features.c?rev=23355&r1=23354&r2=23355&view=diff
==============================================================================
--- trunk/res/res_features.c (original)
+++ trunk/res/res_features.c Sat Apr 29 09:50:18 2006
@@ -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");
Modified: trunk/res/res_monitor.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_monitor.c?rev=23355&r1=23354&r2=23355&view=diff
==============================================================================
--- trunk/res/res_monitor.c (original)
+++ trunk/res/res_monitor.c Sat Apr 29 09:50:18 2006
@@ -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);
- return 0;
- }
- ast_mutex_unlock(&c->lock);
+ ast_channel_unlock(c);
+ return 0;
+ }
+ 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;
}
Modified: trunk/res/snmp/agent.c
URL: http://svn.digium.com/view/asterisk/trunk/res/snmp/agent.c?rev=23355&r1=23354&r2=23355&view=diff
==============================================================================
--- trunk/res/snmp/agent.c (original)
+++ trunk/res/snmp/agent.c Sat Apr 29 09:50:18 2006
@@ -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++;
}
Modified: trunk/udptl.c
URL: http://svn.digium.com/view/asterisk/trunk/udptl.c?rev=23355&r1=23354&r2=23355&view=diff
==============================================================================
--- trunk/udptl.c (original)
+++ trunk/udptl.c Sat Apr 29 09:50:18 2006
@@ -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;
More information about the asterisk-commits
mailing list