mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 10:47:18 +00:00 
			
		
		
		
	main/cdrs: Preserve context/extension when executing a Macro or GoSub
The context/extension in a CDR is generally considered the destination of a call. When looking at a 2-party call CDR, users will typically be presented with the following: context exten channel dest_channel app data default 1000 SIP/8675309 SIP/1000 Dial SIP/1000,,20 However, if the Dial actually takes place in a Macro, the current behaviour in 12 will result in the following CDR: context exten channel dest_channel app data macro-dial s SIP/8675309 SIP/1000 Dial SIP/1000,,20 The same is true of a GoSub: context exten channel dest_channel app data subs dial_stuff SIP/8675309 SIP/1000 Dial SIP/1000,,20 This generally makes the context/exten fields less than useful. It isn't hard to preserve these values in the CDR state machine; however, we need to have something that informs us when a channel is executing a subroutine. Prior to this patch, there isn't anything that does this. This patch solves this problem by adding a new channel flag, AST_FLAG_SUBROUTINE_EXEC. This flag is set on a channel when it executes a Macro or a GoSub. The CDR engine looks for this value when updating a Party A snapshot; if the flag is present, we don't override the context/exten on the main CDR object. In a funny quirk, executing a hangup handler must *not* abide by this logic, as the endbeforehexten logic assumes that the user wants to see data that occurs in hangup logic, which includes those subroutines. Since those execute outside of a typical Dial operation (and will typically have their own dedicated CDR anyway), this is unlikely to cause any heartburn. Review: https://reviewboard.asterisk.org/r/3962/ ASTERISK-24254 #close Reported by: tm1000, Tony Lewis Tested by: Tony Lewis ........ Merged revisions 422718 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 422719 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@422720 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		| @@ -248,6 +248,7 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive | ||||
| 	char *save_macro_context; | ||||
| 	char *save_macro_priority; | ||||
| 	char *save_macro_offset; | ||||
| 	int save_in_subroutine; | ||||
| 	struct ast_datastore *macro_store = ast_channel_datastore_find(chan, ¯o_ds_info, NULL); | ||||
|  | ||||
| 	if (ast_strlen_zero(data)) { | ||||
| @@ -329,6 +330,7 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive | ||||
| 	} | ||||
|  | ||||
| 	/* Save old info */ | ||||
| 	ast_channel_lock(chan); | ||||
| 	oldpriority = ast_channel_priority(chan); | ||||
| 	ast_copy_string(oldexten, ast_channel_exten(chan), sizeof(oldexten)); | ||||
| 	ast_copy_string(oldcontext, ast_channel_context(chan), sizeof(oldcontext)); | ||||
| @@ -355,12 +357,14 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive | ||||
|  | ||||
| 	pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc); | ||||
|  | ||||
| 	save_in_subroutine = ast_test_flag(ast_channel_flags(chan), AST_FLAG_SUBROUTINE_EXEC); | ||||
| 	ast_set_flag(ast_channel_flags(chan), AST_FLAG_SUBROUTINE_EXEC); | ||||
|  | ||||
| 	/* Setup environment for new run */ | ||||
| 	ast_channel_exten_set(chan, "s"); | ||||
| 	ast_channel_context_set(chan, fullmacro); | ||||
| 	ast_channel_priority_set(chan, 1); | ||||
|  | ||||
| 	ast_channel_lock(chan); | ||||
| 	while((cur = strsep(&rest, ",")) && (argc < MAX_ARGS)) { | ||||
| 		const char *argp; | ||||
|   		/* Save copy of old arguments if we're overwriting some, otherwise | ||||
| @@ -513,6 +517,7 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive | ||||
| 	snprintf(depthc, sizeof(depthc), "%d", depth); | ||||
| 	pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc); | ||||
| 	ast_set2_flag(ast_channel_flags(chan), autoloopflag, AST_FLAG_IN_AUTOLOOP); | ||||
| 	ast_set2_flag(ast_channel_flags(chan), save_in_subroutine, AST_FLAG_SUBROUTINE_EXEC); | ||||
|  | ||||
|   	for (x = 1; x < argc; x++) { | ||||
|   		/* Restore old arguments and delete ours */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user