[asterisk-commits] russell: branch russell/chan_refcount r82729 - in /team/russell/chan_refcount...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Sep 17 18:00:19 CDT 2007
Author: russell
Date: Mon Sep 17 18:00:18 2007
New Revision: 82729
URL: http://svn.digium.com/view/asterisk?view=rev&rev=82729
Log:
make code build after removing the lock in ast_channel
Modified:
team/russell/chan_refcount/apps/app_zapscan.c
team/russell/chan_refcount/channels/chan_agent.c
team/russell/chan_refcount/channels/chan_alsa.c
team/russell/chan_refcount/channels/chan_h323.c
team/russell/chan_refcount/channels/chan_iax2.c
team/russell/chan_refcount/channels/chan_local.c
team/russell/chan_refcount/channels/chan_mgcp.c
team/russell/chan_refcount/channels/chan_zap.c
team/russell/chan_refcount/include/asterisk/channel.h
team/russell/chan_refcount/main/channel.c
Modified: team/russell/chan_refcount/apps/app_zapscan.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_zapscan.c?view=diff&rev=82729&r1=82728&r2=82729
==============================================================================
--- team/russell/chan_refcount/apps/app_zapscan.c (original)
+++ team/russell/chan_refcount/apps/app_zapscan.c Mon Sep 17 18:00:18 2007
@@ -346,7 +346,7 @@
if((mygroup = pbx_builtin_getvar_helper(tempchan, "GROUP")) && (!strcmp(mygroup, desired_group))) {
ast_verb(3, "Found Matching Channel %s in group %s\n", tempchan->name, desired_group);
} else {
- ast_mutex_unlock(&tempchan->lock);
+ ast_channel_unlock(tempchan);
lastchan = tempchan;
continue;
}
Modified: team/russell/chan_refcount/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/channels/chan_agent.c?view=diff&rev=82729&r1=82728&r2=82729
==============================================================================
--- team/russell/chan_refcount/channels/chan_agent.c (original)
+++ team/russell/chan_refcount/channels/chan_agent.c Mon Sep 17 18:00:18 2007
@@ -1188,10 +1188,8 @@
ast_copy_string(parent->context, chan->context, sizeof(parent->context));
/* Go ahead and mark the channel as a zombie so that masquerade will
destroy it for us, and we need not call ast_hangup */
- ast_mutex_lock(&parent->lock);
ast_set_flag(chan, AST_FLAG_ZOMBIE);
ast_channel_masquerade(parent, chan);
- ast_mutex_unlock(&parent->lock);
p->abouttograb = 0;
} else {
ast_debug(1, "Sneaky, parent disappeared in the mean time...\n");
Modified: team/russell/chan_refcount/channels/chan_alsa.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/channels/chan_alsa.c?view=diff&rev=82729&r1=82728&r2=82729
==============================================================================
--- team/russell/chan_refcount/channels/chan_alsa.c (original)
+++ team/russell/chan_refcount/channels/chan_alsa.c Mon Sep 17 18:00:18 2007
@@ -508,7 +508,7 @@
static void grab_owner(void)
{
- while (alsa.owner && ast_mutex_trylock(&alsa.owner->lock)) {
+ while (alsa.owner && ast_channel_trylock(alsa.owner)) {
ast_mutex_unlock(&alsalock);
usleep(1);
ast_mutex_lock(&alsalock);
@@ -527,7 +527,7 @@
if (alsa.owner) {
f.subclass = AST_CONTROL_ANSWER;
ast_queue_frame(alsa.owner, &f);
- ast_mutex_unlock(&alsa.owner->lock);
+ ast_channel_unlock(alsa.owner);
}
} else {
ast_verbose(" << Type 'answer' to answer, or use 'autoanswer' for future calls >> \n");
@@ -535,7 +535,7 @@
if (alsa.owner) {
f.subclass = AST_CONTROL_RINGING;
ast_queue_frame(alsa.owner, &f);
- ast_mutex_unlock(&alsa.owner->lock);
+ ast_channel_unlock(alsa.owner);
}
write(sndcmd[1], &res, sizeof(res));
}
@@ -901,7 +901,7 @@
if (alsa.owner) {
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
ast_queue_frame(alsa.owner, &f);
- ast_mutex_unlock(&alsa.owner->lock);
+ ast_channel_unlock(alsa.owner);
}
answer_sound();
}
@@ -950,7 +950,7 @@
f.data = NULL;
f.datalen = 0;
ast_queue_frame(alsa.owner, &f);
- ast_mutex_unlock(&alsa.owner->lock);
+ ast_channel_unlock(alsa.owner);
}
}
@@ -982,7 +982,7 @@
grab_owner();
if (alsa.owner) {
ast_queue_hangup(alsa.owner);
- ast_mutex_unlock(&alsa.owner->lock);
+ ast_channel_unlock(alsa.owner);
}
}
@@ -1010,7 +1010,6 @@
if (alsa.owner) {
if (argc == 3) {
d = argv[2];
- grab_owner();
if (alsa.owner) {
struct ast_frame f = { AST_FRAME_DTMF };
while (*d) {
@@ -1018,7 +1017,6 @@
ast_queue_frame(alsa.owner, &f);
d++;
}
- ast_mutex_unlock(&alsa.owner->lock);
}
} else {
ast_cli(fd, "You're already in a call. You can use this only to dial digits until you hangup\n");
Modified: team/russell/chan_refcount/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/channels/chan_h323.c?view=diff&rev=82729&r1=82728&r2=82729
==============================================================================
--- team/russell/chan_refcount/channels/chan_h323.c (original)
+++ team/russell/chan_refcount/channels/chan_h323.c Mon Sep 17 18:00:18 2007
@@ -2369,13 +2369,7 @@
}
if (!pvt->owner || !ast_channel_trylock(pvt->owner))
break;
-#if 1
-#ifdef DEBUG_THREADS
- ast_log(LOG_NOTICE, "Avoiding H.323 destory deadlock on %s, locked at %ld/%d by %s (%s:%d)\n", call_token, pvt->owner->lock.thread[0], pvt->owner->lock.reentrancy, pvt->owner->lock.func[0], pvt->owner->lock.file[0], pvt->owner->lock.lineno[0]);
-#else
ast_log(LOG_NOTICE, "Avoiding H.323 destory deadlock on %s\n", call_token);
-#endif
-#endif
ast_mutex_unlock(&pvt->lock);
usleep(1);
}
Modified: team/russell/chan_refcount/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/channels/chan_iax2.c?view=diff&rev=82729&r1=82728&r2=82729
==============================================================================
--- team/russell/chan_refcount/channels/chan_iax2.c (original)
+++ team/russell/chan_refcount/channels/chan_iax2.c Mon Sep 17 18:00:18 2007
@@ -1596,14 +1596,14 @@
{
for (;;) {
if (iaxs[callno] && iaxs[callno]->owner) {
- if (ast_mutex_trylock(&iaxs[callno]->owner->lock)) {
+ if (ast_channel_trylock(iaxs[callno]->owner)) {
/* Avoid deadlock by pausing and trying again */
ast_mutex_unlock(&iaxsl[callno]);
usleep(1);
ast_mutex_lock(&iaxsl[callno]);
} else {
ast_queue_frame(iaxs[callno]->owner, f);
- ast_mutex_unlock(&iaxs[callno]->owner->lock);
+ ast_channel_unlock(iaxs[callno]->owner);
break;
}
} else
@@ -1629,14 +1629,14 @@
{
for (;;) {
if (iaxs[callno] && iaxs[callno]->owner) {
- if (ast_mutex_trylock(&iaxs[callno]->owner->lock)) {
+ if (ast_channel_trylock(iaxs[callno]->owner)) {
/* Avoid deadlock by pausing and trying again */
ast_mutex_unlock(&iaxsl[callno]);
usleep(1);
ast_mutex_lock(&iaxsl[callno]);
} else {
ast_queue_hangup(iaxs[callno]->owner);
- ast_mutex_unlock(&iaxs[callno]->owner->lock);
+ ast_channel_unlock(iaxs[callno]->owner);
break;
}
} else
@@ -1663,14 +1663,14 @@
{
for (;;) {
if (iaxs[callno] && iaxs[callno]->owner) {
- if (ast_mutex_trylock(&iaxs[callno]->owner->lock)) {
+ if (ast_channel_trylock(iaxs[callno]->owner)) {
/* Avoid deadlock by pausing and trying again */
ast_mutex_unlock(&iaxsl[callno]);
usleep(1);
ast_mutex_lock(&iaxsl[callno]);
} else {
ast_queue_control_data(iaxs[callno]->owner, control, data, datalen);
- ast_mutex_unlock(&iaxs[callno]->owner->lock);
+ ast_channel_unlock(iaxs[callno]->owner);
break;
}
} else
@@ -2109,7 +2109,7 @@
owner = pvt ? pvt->owner : NULL;
if (owner) {
- if (ast_mutex_trylock(&owner->lock)) {
+ if (ast_channel_trylock(owner)) {
ast_log(LOG_NOTICE, "Avoiding IAX destroy deadlock\n");
ast_mutex_unlock(&iaxsl[callno]);
usleep(1);
@@ -2160,7 +2160,7 @@
}
}
if (owner) {
- ast_mutex_unlock(&owner->lock);
+ ast_channel_unlock(owner);
}
if (callno & 0x4000)
update_max_trunk();
@@ -7543,7 +7543,7 @@
if (iaxs[fr->callno]->owner) {
int orignative;
retryowner:
- if (ast_mutex_trylock(&iaxs[fr->callno]->owner->lock)) {
+ if (ast_channel_trylock(iaxs[fr->callno]->owner)) {
ast_mutex_unlock(&iaxsl[fr->callno]);
usleep(1);
ast_mutex_lock(&iaxsl[fr->callno]);
@@ -7556,7 +7556,7 @@
if (iaxs[fr->callno]->owner->readformat)
ast_set_read_format(iaxs[fr->callno]->owner, iaxs[fr->callno]->owner->readformat);
iaxs[fr->callno]->owner->nativeformats = orignative;
- ast_mutex_unlock(&iaxs[fr->callno]->owner->lock);
+ ast_channel_unlock(iaxs[fr->callno]->owner);
}
} else {
ast_debug(1, "Neat, somebody took away the channel at a magical time but i found it!\n");
@@ -7971,7 +7971,7 @@
iaxs[fr->callno]->owner->nativeformats = iaxs[fr->callno]->peerformat;
ast_verb(3, "Format for call is %s\n", ast_getformatname(iaxs[fr->callno]->owner->nativeformats));
retryowner2:
- if (ast_mutex_trylock(&iaxs[fr->callno]->owner->lock)) {
+ if (ast_channel_trylock(iaxs[fr->callno]->owner)) {
ast_mutex_unlock(&iaxsl[fr->callno]);
usleep(1);
ast_mutex_lock(&iaxsl[fr->callno]);
@@ -7984,7 +7984,7 @@
ast_set_write_format(iaxs[fr->callno]->owner, iaxs[fr->callno]->owner->writeformat);
if (iaxs[fr->callno]->owner->readformat)
ast_set_read_format(iaxs[fr->callno]->owner, iaxs[fr->callno]->owner->readformat);
- ast_mutex_unlock(&iaxs[fr->callno]->owner->lock);
+ ast_channel_unlock(iaxs[fr->callno]->owner);
}
}
}
Modified: team/russell/chan_refcount/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/channels/chan_local.c?view=diff&rev=82729&r1=82728&r2=82729
==============================================================================
--- team/russell/chan_refcount/channels/chan_local.c (original)
+++ team/russell/chan_refcount/channels/chan_local.c Mon Sep 17 18:00:18 2007
@@ -184,11 +184,11 @@
ast_clear_flag(p, LOCAL_GLARE_DETECT);
return 0;
}
- if (ast_mutex_trylock(&other->lock)) {
+ if (ast_channel_trylock(other)) {
/* Failed to lock. Release main lock and try again */
ast_mutex_unlock(&p->lock);
if (us) {
- if (ast_mutex_unlock(&us->lock)) {
+ if (ast_channel_unlock(us)) {
ast_log(LOG_WARNING, "%s wasn't locked while sending %d/%d\n",
us->name, f->frametype, f->subclass);
us = NULL;
@@ -198,12 +198,12 @@
usleep(1);
/* Only we can destroy ourselves, so we can't disappear here */
if (us)
- ast_mutex_lock(&us->lock);
+ ast_channel_lock(us);
ast_mutex_lock(&p->lock);
goto retrylock;
}
ast_queue_frame(other, f);
- ast_mutex_unlock(&other->lock);
+ ast_channel_unlock(other);
ast_clear_flag(p, LOCAL_GLARE_DETECT);
return 0;
}
@@ -245,16 +245,16 @@
/* Lock everything we need, one by one, and give up if
we can't get everything. Remember, we'll get another
chance in just a little bit */
- if (!ast_mutex_trylock(&(p->chan->_bridge)->lock)) {
+ if (!ast_channel_trylock(p->chan->_bridge)) {
if (!ast_check_hangup(p->chan->_bridge)) {
- if (!ast_mutex_trylock(&p->owner->lock)) {
+ if (!ast_channel_trylock(p->owner)) {
if (!ast_check_hangup(p->owner)) {
ast_channel_masquerade(p->owner, p->chan->_bridge);
ast_set_flag(p, LOCAL_ALREADY_MASQED);
}
- ast_mutex_unlock(&p->owner->lock);
+ ast_channel_unlock(p->owner);
}
- ast_mutex_unlock(&(p->chan->_bridge)->lock);
+ ast_channel_unlock(p->chan->_bridge);
}
}
/* We only allow masquerading in one 'direction'... it's important to preserve the state
Modified: team/russell/chan_refcount/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/channels/chan_mgcp.c?view=diff&rev=82729&r1=82728&r2=82729
==============================================================================
--- team/russell/chan_refcount/channels/chan_mgcp.c (original)
+++ team/russell/chan_refcount/channels/chan_mgcp.c Mon Sep 17 18:00:18 2007
@@ -599,9 +599,9 @@
{
for(;;) {
if (sub->owner) {
- if (!ast_mutex_trylock(&sub->owner->lock)) {
+ if (!ast_channel_trylock(sub->owner)) {
ast_queue_frame(sub->owner, f);
- ast_mutex_unlock(&sub->owner->lock);
+ ast_channel_unlock(sub->owner);
break;
} else {
ast_mutex_unlock(&sub->lock);
@@ -617,9 +617,9 @@
{
for(;;) {
if (sub->owner) {
- if (!ast_mutex_trylock(&sub->owner->lock)) {
+ if (!ast_channel_trylock(sub->owner)) {
ast_queue_hangup(sub->owner);
- ast_mutex_unlock(&sub->owner->lock);
+ ast_channel_unlock(sub->owner);
break;
} else {
ast_mutex_unlock(&sub->lock);
Modified: team/russell/chan_refcount/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/channels/chan_zap.c?view=diff&rev=82729&r1=82728&r2=82729
==============================================================================
--- team/russell/chan_refcount/channels/chan_zap.c (original)
+++ team/russell/chan_refcount/channels/chan_zap.c Mon Sep 17 18:00:18 2007
@@ -924,13 +924,13 @@
#endif
for (;;) {
if (p->subs[a].owner) {
- if (ast_mutex_trylock(&p->subs[a].owner->lock)) {
+ if (ast_channel_trylock(p->subs[a].owner)) {
ast_mutex_unlock(&p->lock);
usleep(1);
ast_mutex_lock(&p->lock);
} else {
ast_queue_frame(p->subs[a].owner, &ast_null_frame);
- ast_mutex_unlock(&p->subs[a].owner->lock);
+ ast_channel_unlock(p->subs[a].owner);
break;
}
} else
@@ -971,13 +971,13 @@
#endif
for (;;) {
if (p->owner) {
- if (ast_mutex_trylock(&p->owner->lock)) {
+ if (ast_channel_trylock(p->owner)) {
ast_mutex_unlock(&p->lock);
usleep(1);
ast_mutex_lock(&p->lock);
} else {
ast_queue_frame(p->owner, f);
- ast_mutex_unlock(&p->owner->lock);
+ ast_channel_unlock(p->owner);
break;
}
} else
@@ -3474,23 +3474,22 @@
if (flags & (AST_BRIDGE_DTMF_CHANNEL_0 | AST_BRIDGE_DTMF_CHANNEL_1))
return AST_BRIDGE_FAILED_NOWARN;
- ast_mutex_lock(&c0->lock);
- ast_mutex_lock(&c1->lock);
+ ast_channel_lock_both(c0, c1);
p0 = c0->tech_pvt;
p1 = c1->tech_pvt;
/* cant do pseudo-channels here */
if (!p0 || (!p0->sig) || !p1 || (!p1->sig)) {
- ast_mutex_unlock(&c0->lock);
- ast_mutex_unlock(&c1->lock);
+ ast_channel_unlock(c0);
+ ast_channel_unlock(c1);
return AST_BRIDGE_FAILED_NOWARN;
}
oi0 = zt_get_index(c0, p0, 0);
oi1 = zt_get_index(c1, p1, 0);
if ((oi0 < 0) || (oi1 < 0)) {
- ast_mutex_unlock(&c0->lock);
- ast_mutex_unlock(&c1->lock);
+ ast_channel_unlock(c0);
+ ast_channel_unlock(c1);
return AST_BRIDGE_FAILED;
}
@@ -3503,16 +3502,16 @@
if (ast_mutex_trylock(&p0->lock)) {
/* Don't block, due to potential for deadlock */
- ast_mutex_unlock(&c0->lock);
- ast_mutex_unlock(&c1->lock);
+ ast_channel_unlock(c0);
+ ast_channel_unlock(c1);
ast_log(LOG_NOTICE, "Avoiding deadlock...\n");
return AST_BRIDGE_RETRY;
}
if (ast_mutex_trylock(&p1->lock)) {
/* Don't block, due to potential for deadlock */
ast_mutex_unlock(&p0->lock);
- ast_mutex_unlock(&c0->lock);
- ast_mutex_unlock(&c1->lock);
+ ast_channel_unlock(c0);
+ ast_channel_unlock(c1);
ast_log(LOG_NOTICE, "Avoiding deadlock...\n");
return AST_BRIDGE_RETRY;
}
@@ -3617,8 +3616,8 @@
ast_mutex_unlock(&p0->lock);
ast_mutex_unlock(&p1->lock);
- ast_mutex_unlock(&c0->lock);
- ast_mutex_unlock(&c1->lock);
+ ast_channel_unlock(c0);
+ ast_channel_unlock(c1);
/* Native bridge failed */
if ((!master || !slave) && !nothingok) {
@@ -3641,8 +3640,8 @@
/* Here's our main loop... Start by locking things, looking for private parts,
and then balking if anything is wrong */
- ast_mutex_lock(&c0->lock);
- ast_mutex_lock(&c1->lock);
+ ast_channel_lock_both(c0, c1);
+
p0 = c0->tech_pvt;
p1 = c1->tech_pvt;
@@ -3650,8 +3649,9 @@
i0 = zt_get_index(c0, p0, 1);
if (op1 == p1)
i1 = zt_get_index(c1, p1, 1);
- ast_mutex_unlock(&c0->lock);
- ast_mutex_unlock(&c1->lock);
+
+ ast_channel_unlock(c0);
+ ast_channel_unlock(c1);
if (!timeoutms ||
(op0 != p0) ||
@@ -3821,7 +3821,7 @@
return -1;
}
/* Orphan the channel after releasing the lock */
- ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock);
+ ast_channel_unlock(p->subs[SUB_THREEWAY].owner);
unalloc_sub(p, SUB_THREEWAY);
} else if (ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) {
ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD);
@@ -3850,7 +3850,7 @@
}
/* Three-way is now the REAL */
swap_subs(p, SUB_THREEWAY, SUB_REAL);
- ast_mutex_unlock(&p->subs[SUB_REAL].owner->lock);
+ ast_channel_unlock(p->subs[SUB_REAL].owner);
unalloc_sub(p, SUB_THREEWAY);
/* Tell the caller not to hangup */
return 1;
@@ -4167,15 +4167,15 @@
unsigned int mssinceflash;
/* Here we have to retain the lock on both the main channel, the 3-way channel, and
the private structure -- not especially easy or clean */
- while (p->subs[SUB_THREEWAY].owner && ast_mutex_trylock(&p->subs[SUB_THREEWAY].owner->lock)) {
+ while (p->subs[SUB_THREEWAY].owner && ast_channel_trylock(p->subs[SUB_THREEWAY].owner)) {
/* Yuck, didn't get the lock on the 3-way, gotta release everything and re-grab! */
ast_mutex_unlock(&p->lock);
- ast_mutex_unlock(&ast->lock);
+ ast_channel_unlock(ast);
usleep(1);
/* We can grab ast and p in that order, without worry. We should make sure
nothing seriously bad has happened though like some sort of bizarre double
masquerade! */
- ast_mutex_lock(&ast->lock);
+ ast_channel_lock(ast);
ast_mutex_lock(&p->lock);
if (p->owner != ast) {
ast_log(LOG_WARNING, "This isn't good...\n");
@@ -4195,7 +4195,7 @@
ast_queue_hangup(p->subs[SUB_THREEWAY].owner);
p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
ast_debug(1, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel);
- ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock);
+ ast_channel_unlock(p->subs[SUB_THREEWAY].owner);
} else if ((ast->pbx) || (ast->_state == AST_STATE_UP)) {
if (p->transfer) {
/* In any case this isn't a threeway call anymore */
@@ -4203,7 +4203,7 @@
p->subs[SUB_THREEWAY].inthreeway = 0;
/* Only attempt transfer if the phone is ringing; why transfer to busy tone eh? */
if (!p->transfertobusy && ast->_state == AST_STATE_BUSY) {
- ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock);
+ ast_channel_unlock(p->subs[SUB_THREEWAY].owner);
/* Swap subs and dis-own channel */
swap_subs(p, SUB_THREEWAY, SUB_REAL);
p->owner = NULL;
@@ -4213,21 +4213,21 @@
if ((res = attempt_transfer(p)) < 0) {
p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
if (p->subs[SUB_THREEWAY].owner)
- ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock);
+ ast_channel_unlock(p->subs[SUB_THREEWAY].owner);
} else if (res) {
/* Don't actually hang up at this point */
if (p->subs[SUB_THREEWAY].owner)
- ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock);
+ ast_channel_unlock(p->subs[SUB_THREEWAY].owner);
break;
}
}
} else {
p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
if (p->subs[SUB_THREEWAY].owner)
- ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock);
+ ast_channel_unlock(p->subs[SUB_THREEWAY].owner);
}
} else {
- ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock);
+ ast_channel_unlock(p->subs[SUB_THREEWAY].owner);
/* Swap subs and dis-own channel */
swap_subs(p, SUB_THREEWAY, SUB_REAL);
p->owner = NULL;
@@ -9238,7 +9238,7 @@
do {
redo = 0;
for (x = 0; x < 3; x++) {
- while (p->subs[x].owner && ast_mutex_trylock(&p->subs[x].owner->lock)) {
+ while (p->subs[x].owner && ast_channel_trylock(p->subs[x].owner)) {
redo++;
ast_mutex_unlock(&p->lock);
usleep(1);
@@ -9246,7 +9246,7 @@
}
if (p->subs[x].owner) {
ast_queue_hangup(p->subs[x].owner);
- ast_mutex_unlock(&p->subs[x].owner->lock);
+ ast_channel_unlock(p->subs[x].owner);
}
}
} while (redo);
Modified: team/russell/chan_refcount/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/include/asterisk/channel.h?view=diff&rev=82729&r1=82728&r2=82729
==============================================================================
--- team/russell/chan_refcount/include/asterisk/channel.h (original)
+++ team/russell/chan_refcount/include/asterisk/channel.h Mon Sep 17 18:00:18 2007
@@ -1545,11 +1545,26 @@
*/
const char *ast_channel_reason2str(int reason);
-#define ast_channel_lock(c) ao2_lock(c)
-#define ast_channel_unlock(c) ao2_unlock(c)
-#define ast_channel_trylock(c) ao2_trylock(c)
-
-#define ast_channel_lock_both(c1, c2) ao2_lock_both(c1, c2)
+static force_inline int ast_channel_lock(struct ast_channel *chan)
+{
+ return ao2_lock(chan);
+}
+
+static force_inline int ast_channel_unlock(struct ast_channel *chan)
+{
+ return ao2_unlock(chan);
+}
+
+static force_inline int ast_channel_trylock(struct ast_channel *chan)
+{
+ return ao2_trylock(chan);
+}
+
+static force_inline int ast_channel_lock_both(struct ast_channel *chan1,
+ struct ast_channel *chan2)
+{
+ return ao2_lock_both(chan1, chan2);
+}
static force_inline struct ast_channel *ast_channel_ref(struct ast_channel *chan)
{
Modified: team/russell/chan_refcount/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/main/channel.c?view=diff&rev=82729&r1=82728&r2=82729
==============================================================================
--- team/russell/chan_refcount/main/channel.c (original)
+++ team/russell/chan_refcount/main/channel.c Mon Sep 17 18:00:18 2007
@@ -677,7 +677,7 @@
if (chan->pbx)
ast_log(LOG_WARNING, "PBX may not have been terminated properly on '%s'\n", chan->name);
free_cid(&chan->cid);
- ast_mutex_destroy(&chan->lock);
+
/* Close pipes if appropriate */
if ((fd = chan->alertpipe[0]) > -1)
close(fd);
@@ -870,8 +870,6 @@
headp = &tmp->varshead;
AST_LIST_HEAD_INIT_NOLOCK(headp);
-
- ast_mutex_init(&tmp->lock);
AST_LIST_HEAD_INIT_NOLOCK(&tmp->datastores);
@@ -3464,8 +3462,6 @@
/* We need the clone's lock, too */
ast_channel_lock(clone);
- ast_debug(2, "Got clone lock for masquerade on '%s' at %p\n", clone->name, &clone->lock);
-
/* Having remembered the original read/write formats, we turn off any translation on either
one */
free_translation(clone);
More information about the asterisk-commits
mailing list