Fix use count for agent/local (bug #2996 et al)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4425 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
6c009e04ff
commit
f975cf1ad6
|
@ -561,6 +561,10 @@ static int agent_hangup(struct ast_channel *ast)
|
|||
* as in apps/app_chanisavail.c:chanavail_exec()
|
||||
*/
|
||||
|
||||
ast_mutex_lock(&usecnt_lock);
|
||||
usecnt--;
|
||||
ast_mutex_unlock(&usecnt_lock);
|
||||
|
||||
ast_log(LOG_DEBUG, "Hangup called for state %s\n", ast_state2str(ast->_state));
|
||||
if (p->start && (ast->_state != AST_STATE_UP)) {
|
||||
howlong = time(NULL) - p->start;
|
||||
|
|
|
@ -312,6 +312,10 @@ static int local_hangup(struct ast_channel *ast)
|
|||
p->owner = NULL;
|
||||
ast->pvt->pvt = NULL;
|
||||
|
||||
ast_mutex_lock(&usecnt_lock);
|
||||
usecnt--;
|
||||
ast_mutex_unlock(&usecnt_lock);
|
||||
|
||||
if (!p->owner && !p->chan) {
|
||||
/* Okay, done with the private part now, too. */
|
||||
glaredetect = p->glaredetect;
|
||||
|
@ -452,6 +456,7 @@ static struct ast_channel *local_new(struct local_pvt *p, int state)
|
|||
p->chan = tmp2;
|
||||
ast_mutex_lock(&usecnt_lock);
|
||||
usecnt++;
|
||||
usecnt++;
|
||||
ast_mutex_unlock(&usecnt_lock);
|
||||
ast_update_use_count();
|
||||
strncpy(tmp->context, p->context, sizeof(tmp->context)-1);
|
||||
|
|
Reference in New Issue