Fix use count for agent/local (bug #2996 et al)
authorMark Spencer <markster@digium.com>
Sat, 11 Dec 2004 04:46:49 +0000 (04:46 +0000)
committerMark Spencer <markster@digium.com>
Sat, 11 Dec 2004 04:46:49 +0000 (04:46 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4425 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_agent.c
channels/chan_local.c

index 4421deb..40a29ee 100755 (executable)
@@ -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;
index fc5c74f..b1998f1 100755 (executable)
@@ -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);