From: Mark Spencer Date: Tue, 8 Apr 2003 13:50:04 +0000 (+0000) Subject: Unlink local channels X-Git-Tag: 0.4.0~60 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9cc2aa39d0f6f523818482ebb6668a219810aa22;p=thirdparty%2Fasterisk.git Unlink local channels git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@778 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_local.c b/channels/chan_local.c index feabb36bad..c8d4371e7b 100755 --- a/channels/chan_local.c +++ b/channels/chan_local.c @@ -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; }