Unlink local channels
authorMark Spencer <markster@digium.com>
Tue, 8 Apr 2003 13:50:04 +0000 (13:50 +0000)
committerMark Spencer <markster@digium.com>
Tue, 8 Apr 2003 13:50:04 +0000 (13:50 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@778 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_local.c

index feabb36..c8d4371 100755 (executable)
@@ -220,6 +220,7 @@ static int local_hangup(struct ast_channel *ast)
        struct local_pvt *p = ast->pvt->pvt;
        int isoutbound = IS_OUTBOUND(ast, p);
        struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
+       struct local_pvt *cur, *prev=NULL;
        ast_pthread_mutex_lock(&p->lock);
        if (isoutbound)
                p->chan = NULL;
@@ -229,6 +230,22 @@ static int local_hangup(struct ast_channel *ast)
        if (!p->owner && !p->chan) {
                /* Okay, done with the private part now, too. */
                ast_pthread_mutex_unlock(&p->lock);
+               /* Remove from list */
+               ast_pthread_mutex_lock(&locallock);
+               cur = locals;
+               while(cur) {
+                       if (cur == p) {
+                               if (prev)
+                                       prev->next == cur->next;
+                               else
+                                       locals = cur->next;
+                               break;
+                       }
+                       prev = cur;
+                       cur = cur->next;
+               }
+               ast_pthread_mutex_unlock(&locallock);
+               /* And destroy */
                free(p);
                return 0;
        }