Summary: | ASTERISK-03714: [patch] Channel variables not set on cloned channels during redirect | ||
Reporter: | Abhishek Tiwari (abhi) | Labels: | |
Date Opened: | 2005-03-19 19:30:20.000-0600 | Date Closed: | 2008-01-15 15:28:09.000-0600 |
Priority: | Minor | Regression? | No |
Status: | Closed/Complete | Components: | Core/General |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) channel.c.patch ( 1) list_append_rev1.diff.txt | |
Description: | When two channels are in a native bridge if a redirect (from manager api) is used, for both the channel using "extraChannel" variable, the channel variables of one of the channels are lost. It is due to the channel variables not being copied during cloning in ast_do_masquerade. The variables lost are of the channel which is not running pbx. ****** ADDITIONAL INFORMATION ****** The problem is in the new function clone_variables defined in channel.c. Reverting to the original code (channel.c of asterisk release 1.0.6 in cvs) works. | ||
Comments: | By: Mark Spencer (markster) 2005-03-19 21:51:51.000-0600 Are you saying that even the inherited channels (e.g. __foo) are not maintained? By: Abhishek Tiwari (abhi) 2005-03-20 02:29:53.000-0600 Sorry for reporting this under zaptel. Donot know how to move this to core asterisk. No. Only one of the variable of the list of 3 user variables and 3 inherited variables was being preserved (assuming DIALPEERNAME, DIALPEERNUMBER variables as inherited). By: Kevin P. Fleming (kpfleming) 2005-03-20 09:08:53.000-0600 Can you post a debug log or something showing exactly what variables existing prior to the redirect and what existed after? By: Abhishek Tiwari (abhi) 2005-03-20 17:12:09.000-0600 In function clone_variables() in file channel.c (v 1.175) the lines (line no 2321): if (AST_LIST_FIRST(&clone->varshead)) AST_LIST_INSERT_TAIL(&original->varshead, AST_LIST_FIRST(&clone->varshead), entries); copies only the head of the list. The attached patch fixes this by copying the entire list. Patch disclaimed. By: Kevin P. Fleming (kpfleming) 2005-03-20 17:36:46.000-0600 I do not know how Mark and I both missed that when we were working on this code before... this is correct, the current code only moves the first entry from the clone channel's variable list to the new channel (since AST_LIST_INSERT_TAIL, which calls AST_LIST_INSERT_AFTER, overwrites the ->next pointer during the move, it becomes disconnected from its old list). When I wrote that block I was assuming (wrongly) that moving the head entry would be adequate, because it would retain the link to the remainder of the list. edited on: 03-20-05 17:37 By: Mark Spencer (markster) 2005-03-20 20:14:09.000-0600 But shouldn't we then have a macro to do this? Am I missing something or are we creating a loop where there should be a single O(1) operation? By: Kevin P. Fleming (kpfleming) 2005-03-20 20:39:52.000-0600 Yes, it would be more efficient to have a macro to append an entire list to another list. By: Kevin P. Fleming (kpfleming) 2005-03-20 21:03:16.000-0600 I opted instead to change the operation of AST_LIST_INSERT_TAIL, since there was no need for it to be modifying the link field in the element being appended. I updated the doxygen docs for it as well. I also cleaned up some formatting (whitespace) in the header file, and eliminated macros-using-macros where they were not needed. Disclaimer is on file. By: Mark Spencer (markster) 2005-03-20 22:24:27.000-0600 Added to CVS, thanks! By: Digium Subversion (svnbot) 2008-01-15 15:28:09.000-0600 Repository: asterisk Revision: 5222 U trunk/include/asterisk/linkedlists.h ------------------------------------------------------------------------ r5222 | markster | 2008-01-15 15:28:09 -0600 (Tue, 15 Jan 2008) | 2 lines Fix channel variables on cloned channels (bug ASTERISK-3714) ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=5222 |