[svn-commits] russell: trunk r38077 - in /trunk/channels:
chan_iax2.c chan_sip.c chan_zap.c
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Fri Jul 21 17:33:57 MST 2006
Author: russell
Date: Fri Jul 21 19:33:56 2006
New Revision: 38077
URL: http://svn.digium.com/view/asterisk?rev=38077&view=rev
Log:
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
Modified:
trunk/channels/chan_iax2.c
trunk/channels/chan_sip.c
trunk/channels/chan_zap.c
Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?rev=38077&r1=38076&r2=38077&view=diff
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Fri Jul 21 19:33:56 2006
@@ -173,8 +173,7 @@
static struct ast_netsock_list *netsock;
static int defaultsockfd = -1;
-static int usecnt;
-AST_MUTEX_DEFINE_STATIC(usecnt_lock);
+static int usecnt = 0;
int (*iax2_regfunk)(char *username, int onoff) = NULL;
@@ -1688,14 +1687,10 @@
c->tech_pvt = NULL;
ast_queue_hangup(c);
pvt->owner = NULL;
- 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();
}
ast_mutex_unlock(&iaxsl[callno]);
- ast_update_use_count();
return 0;
}
@@ -3293,9 +3288,7 @@
for (v = i->vars ; v ; v = v->next)
pbx_builtin_setvar_helper(tmp, v->name, v->value);
- ast_mutex_lock(&usecnt_lock);
- usecnt++;
- ast_mutex_unlock(&usecnt_lock);
+ ast_atomic_fetchadd_int(&usecnt, 1);
ast_update_use_count();
return tmp;
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=38077&r1=38076&r2=38077&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Fri Jul 21 19:33:56 2006
@@ -537,8 +537,6 @@
static int regobjs = 0; /*!< Registry objects */
static struct ast_flags global_flags[2] = {{0}}; /*!< global SIP_ flags */
-
-AST_MUTEX_DEFINE_STATIC(usecnt_lock);
/*! \brief Protect the SIP dialog list (of sip_pvt's) */
AST_MUTEX_DEFINE_STATIC(iflock);
@@ -3201,9 +3199,7 @@
p->owner = NULL;
ast->tech_pvt = NULL;
- ast_mutex_lock(&usecnt_lock);
- usecnt--;
- ast_mutex_unlock(&usecnt_lock);
+ ast_atomic_fetchadd_int(&usecnt, -1);
ast_update_use_count();
ast_set_flag(&locflags, SIP_NEEDDESTROY);
@@ -3672,9 +3668,8 @@
if (!ast_strlen_zero(i->language))
ast_string_field_set(tmp, language, i->language);
i->owner = tmp;
- ast_mutex_lock(&usecnt_lock);
- usecnt++;
- ast_mutex_unlock(&usecnt_lock);
+ ast_atomic_fetchadd_int(&usecnt, 1);
+ ast_update_use_count();
ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
Modified: trunk/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_zap.c?rev=38077&r1=38076&r2=38077&view=diff
==============================================================================
--- trunk/channels/chan_zap.c (original)
+++ trunk/channels/chan_zap.c Fri Jul 21 19:33:56 2006
@@ -327,7 +327,6 @@
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 @@
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 @@
}
}
- ast_mutex_lock(&usecnt_lock);
- usecnt++;
- ast_mutex_unlock(&usecnt_lock);
+ ast_atomic_fetchadd_int(&usecnt, 1);
ast_update_use_count();
return tmp;
More information about the svn-commits
mailing list