dect
/
asterisk
Archived
13
0
Fork 0

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: http://svn.digium.com/svn/asterisk/trunk@38077 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
russell 2006-07-22 00:33:56 +00:00
parent 593233e983
commit ffb56d9d39
3 changed files with 9 additions and 28 deletions

View File

@ -173,8 +173,7 @@ static int timingfd = -1; /* Timing file descriptor */
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 @@ static int iax2_predestroy(int callno)
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 @@ static struct ast_channel *ast_iax2_new(int callno, int state, int capability)
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;

View File

@ -538,8 +538,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 @@ static int sip_hangup(struct ast_channel *ast)
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 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
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);

View File

@ -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;