diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-12-02 00:26:12 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-12-02 00:26:12 +0000 |
commit | e0166f35d4e6e7709c54ae041a3b99bb83872891 (patch) | |
tree | d8e2853ce36907ddce3adf481f576f68a1934508 /channels | |
parent | d4a94dacb670519b35bc6db0729005d9082418f4 (diff) |
allow variables to exist on both 'halves' of the Local channel (issue #5810)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@7270 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_local.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/channels/chan_local.c b/channels/chan_local.c index 6dec650ab..f843fd95d 100644 --- a/channels/chan_local.c +++ b/channels/chan_local.c @@ -320,6 +320,8 @@ static int local_call(struct ast_channel *ast, char *dest, int timeout) { struct local_pvt *p = ast->tech_pvt; int res; + struct ast_var_t *varptr = NULL, *new; + size_t len, namelen; ast_mutex_lock(&p->lock); if (p->owner->cid.cid_num) @@ -345,9 +347,22 @@ static int local_call(struct ast_channel *ast, char *dest, int timeout) strncpy(p->chan->language, p->owner->language, sizeof(p->chan->language) - 1); strncpy(p->chan->accountcode, p->owner->accountcode, sizeof(p->chan->accountcode) - 1); p->chan->cdrflags = p->owner->cdrflags; - /* move the channel variables from the incoming channel to the outgoing channel */ - AST_LIST_HEAD_SET_NOLOCK(&p->chan->varshead, AST_LIST_FIRST(&p->owner->varshead)); - AST_LIST_HEAD_INIT_NOLOCK(&p->owner->varshead); + + /* copy the channel variables from the incoming channel to the outgoing channel */ + /* Note that due to certain assumptions, they MUST be in the same order */ + AST_LIST_TRAVERSE(&p->owner->varshead, varptr, entries) { + namelen = strlen(varptr->name); + len = sizeof(struct ast_var_t) + namelen + strlen(varptr->value) + 2; + new = malloc(len); + if (new) { + memcpy(new, varptr, len); + new->value = &(new->name[0]) + namelen + 1; + AST_LIST_INSERT_TAIL(&p->chan->varshead, new, entries); + } else { + ast_log(LOG_ERROR, "Out of memory!\n"); + } + } + p->launchedpbx = 1; /* Start switch on sub channel */ |