Index: channel.c =================================================================== --- channel.c (revision 20298) +++ channel.c (working copy) @@ -313,9 +313,9 @@ static int ast_check_hangup_locked(struct ast_channel *chan) { int res; - ast_mutex_lock(&chan->lock); + ast_channel_lock(chan); res = ast_check_hangup(chan); - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); return res; } @@ -682,13 +682,13 @@ ast_log(LOG_WARNING, "Unable to duplicate frame\n"); return -1; } - ast_mutex_lock(&chan->lock); + ast_channel_lock(chan); prev = NULL; for (cur = chan->readq; cur; cur = cur->next) { if ((cur->frametype == AST_FRAME_CONTROL) && (cur->subclass == AST_CONTROL_HANGUP)) { /* Don't bother actually queueing anything after a hangup */ ast_frfree(f); - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); return 0; } prev = cur; @@ -702,7 +702,7 @@ } else { ast_log(LOG_DEBUG, "Dropping voice to exceptionally long queue on %s\n", chan->name); ast_frfree(f); - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); return 0; } } @@ -721,7 +721,7 @@ } else if (ast_test_flag(chan, AST_FLAG_BLOCKING)) { pthread_kill(chan->blocker, SIGURG); } - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); return 0; } @@ -730,9 +730,9 @@ { struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP }; /* Yeah, let's not change a lock-critical value without locking */ - if (!ast_mutex_trylock(&chan->lock)) { + if (!ast_channel_trylock(chan)) { chan->_softhangup |= AST_SOFTHANGUP_DEV; - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); } return ast_queue_frame(chan, &f); } @@ -832,7 +832,7 @@ } } /* exit if chan not found or mutex acquired successfully */ - done = (c == NULL) || (ast_mutex_trylock(&c->lock) == 0); + done = (c == NULL) || (ast_channel_trylock(c) == 0); /* this is slightly unsafe, as we _should_ hold the lock to access c->name */ if (!done && c) ast_log(LOG_DEBUG, "Avoiding %s for '%s'\n", msg, c->name); @@ -938,8 +938,8 @@ AST_LIST_REMOVE(&channels, chan, chan_list); /* Lock and unlock the channel just to be sure nobody has it locked still */ - ast_mutex_lock(&chan->lock); - ast_mutex_unlock(&chan->lock); + ast_channel_lock(chan); + ast_channel_unlock(chan); if (chan->tech_pvt) { ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n", chan->name); free(chan->tech_pvt); @@ -1253,9 +1253,9 @@ int ast_softhangup(struct ast_channel *chan, int cause) { int res; - ast_mutex_lock(&chan->lock); + ast_channel_lock(chan); res = ast_softhangup_nolock(chan, cause); - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); return res; } @@ -1485,7 +1485,7 @@ ast_channel_lock(chan); /* Stop if we're a zombie or need a soft hangup */ if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); return -1; } switch(chan->_state) { @@ -1510,7 +1510,7 @@ void ast_deactivate_generator(struct ast_channel *chan) { - ast_mutex_lock(&chan->lock); + ast_channel_lock(chan); if (chan->generatordata) { if (chan->generator && chan->generator->release) chan->generator->release(chan, chan->generatordata); @@ -1520,7 +1520,7 @@ ast_clear_flag(chan, AST_FLAG_WRITE_INT); ast_settimeout(chan, 0, NULL, NULL); } - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); } static int generator_force(void *data) @@ -2100,7 +2100,7 @@ chan->fin &= 0x80000000; else chan->fin++; - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); return f; } @@ -2127,15 +2127,15 @@ { int res = -1; - ast_mutex_lock(&chan->lock); + ast_channel_lock(chan); /* Stop if we're a zombie or need a soft hangup */ if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); return -1; } if (chan->tech->indicate) res = chan->tech->indicate(chan, condition); - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); if (!chan->tech->indicate || res) { /* * Device does not support (that) indication, lets fake @@ -2683,11 +2683,11 @@ return anyway. */ int res = -1; /* Stop if we're a zombie or need a soft hangup */ - ast_mutex_lock(&chan->lock); + ast_channel_lock(chan); if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) if (chan->tech->call) res = chan->tech->call(chan, addr, timeout); - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); return res; } @@ -2703,7 +2703,7 @@ int res = -1; /* Stop if we're a zombie or need a soft hangup */ - ast_mutex_lock(&chan->lock); + ast_channel_lock(chan); if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) { if (chan->tech->transfer) { res = chan->tech->transfer(chan, dest); @@ -2712,7 +2712,7 @@ } else res = 0; } - ast_mutex_unlock(&chan->lock); + ast_channel_unlock(chan); return res; } @@ -2874,11 +2874,11 @@ ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n", original->name); return -1; } - ast_mutex_lock(&original->lock); - while(ast_mutex_trylock(&clone->lock)) { - ast_mutex_unlock(&original->lock); + ast_channel_lock(original); + while(ast_channel_trylock(clone)) { + ast_channel_unlock(original); usleep(1); - ast_mutex_lock(&original->lock); + ast_channel_lock(original); } ast_log(LOG_DEBUG, "Planning to masquerade channel %s into the structure of %s\n", clone->name, original->name); @@ -2896,8 +2896,8 @@ ast_log(LOG_DEBUG, "Done planning to masquerade channel %s into the structure of %s\n", clone->name, original->name); res = 0; } - ast_mutex_unlock(&clone->lock); - ast_mutex_unlock(&original->lock); + ast_channel_unlock(clone); + ast_channel_unlock(original); return res; }