summaryrefslogtreecommitdiff
path: root/channels/chan_zap.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2006-07-22 00:33:56 +0000
committerRussell Bryant <russell@russellbryant.com>2006-07-22 00:33:56 +0000
commitd897bd41c2e2591d159c7380866508bab45ba798 (patch)
treec447fd9cdf82a9a6fe67d8a4c0e414c08f4ad34d /channels/chan_zap.c
parent41ab9c501517804eadbd65987059a17ceef7af80 (diff)
use ast_atomic_fetchadd_int in chan_zap, sip, and iax2 for usecount handling
and fix a couple little things in passing - usecnt was not initialized in chan_iax2 - ast_update_use_count() was not called after incrementing the count in chan_sip git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@38077 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_zap.c')
-rw-r--r--channels/chan_zap.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 1e005b00a..3aa84d006 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -327,7 +327,6 @@ static int gendigittimeout = 8000;
static int matchdigittimeout = 3000;
static int usecnt = 0;
-AST_MUTEX_DEFINE_STATIC(usecnt_lock);
/*! \brief Protect the interface list (of zt_pvt's) */
AST_MUTEX_DEFINE_STATIC(iflock);
@@ -2636,11 +2635,7 @@ static int zt_hangup(struct ast_channel *ast)
p->oprmode = 0;
ast->tech_pvt = NULL;
ast_mutex_unlock(&p->lock);
- ast_mutex_lock(&usecnt_lock);
- usecnt--;
- if (usecnt < 0)
- ast_log(LOG_WARNING, "Usecnt < 0???\n");
- ast_mutex_unlock(&usecnt_lock);
+ ast_atomic_fetchadd_int(&usecnt, -1);
ast_update_use_count();
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "Hungup '%s'\n", ast->name);
@@ -5247,9 +5242,7 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
}
}
- ast_mutex_lock(&usecnt_lock);
- usecnt++;
- ast_mutex_unlock(&usecnt_lock);
+ ast_atomic_fetchadd_int(&usecnt, 1);
ast_update_use_count();
return tmp;