mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-15 17:27:02 +00:00
Fix use count for agent/local (bug #2996 et al)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4425 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -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
Block a user