mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 18:55:19 +00:00 
			
		
		
		
	Make the Hangup application set a softhangup flag.
The Hangup application used to just return -1 to cause normal dialplan execution to hangup a channel. For the non-normal execution routines like predial and connected-line interception routines, the hangup request would exit the routine early but otherwise be ignored. * Made the Hangup application not allow setting a cause code of zero. A zero cause code is not defined. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368979 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		
							
								
								
									
										35
									
								
								main/pbx.c
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								main/pbx.c
									
									
									
									
									
								
							| @@ -10020,29 +10020,32 @@ static int pbx_builtin_setamaflags(struct ast_channel *chan, const char *data) | ||||
|  */ | ||||
| static int pbx_builtin_hangup(struct ast_channel *chan, const char *data) | ||||
| { | ||||
| 	int cause; | ||||
|  | ||||
| 	ast_set_hangupsource(chan, "dialplan/builtin", 0); | ||||
|  | ||||
| 	if (!ast_strlen_zero(data)) { | ||||
| 		int cause; | ||||
| 		char *endptr; | ||||
|  | ||||
| 		if ((cause = ast_str2cause(data)) > -1) { | ||||
| 			ast_channel_hangupcause_set(chan, cause); | ||||
| 			return -1; | ||||
| 		cause = ast_str2cause(data); | ||||
| 		if (cause <= 0) { | ||||
| 			if (sscanf(data, "%30d", &cause) != 1 || cause <= 0) { | ||||
| 				ast_log(LOG_WARNING, "Invalid cause given to Hangup(): \"%s\"\n", data); | ||||
| 				cause = 0; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		cause = strtol((const char *) data, &endptr, 10); | ||||
| 		if (cause != 0 || (data != endptr)) { | ||||
| 			ast_channel_hangupcause_set(chan, cause); | ||||
| 			return -1; | ||||
| 		} | ||||
|  | ||||
| 		ast_log(LOG_WARNING, "Invalid cause given to Hangup(): \"%s\"\n", (char *) data); | ||||
| 	} else { | ||||
| 		cause = 0; | ||||
| 	} | ||||
|  | ||||
| 	if (!ast_channel_hangupcause(chan)) { | ||||
| 		ast_channel_hangupcause_set(chan, AST_CAUSE_NORMAL_CLEARING); | ||||
| 	ast_channel_lock(chan); | ||||
| 	if (cause <= 0) { | ||||
| 		cause = ast_channel_hangupcause(chan); | ||||
| 		if (cause <= 0) { | ||||
| 			cause = AST_CAUSE_NORMAL_CLEARING; | ||||
| 		} | ||||
| 	} | ||||
| 	ast_channel_hangupcause_set(chan, cause); | ||||
| 	ast_softhangup_nolock(chan, AST_SOFTHANGUP_EXPLICIT); | ||||
| 	ast_channel_unlock(chan); | ||||
|  | ||||
| 	return -1; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user