mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 18:55:19 +00:00 
			
		
		
		
	Remove dead code since pri_grab() can never fail.
Dead code makes programmers sick. I am sick of looking at it. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@345546 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		| @@ -1933,15 +1933,12 @@ static void *pri_ss_thread(void *data) | |||||||
| 			&& !ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) { | 			&& !ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) { | ||||||
| 			sig_pri_lock_private(p); | 			sig_pri_lock_private(p); | ||||||
| 			if (p->pri->pri) { | 			if (p->pri->pri) { | ||||||
| 				if (!pri_grab(p, p->pri)) { | 				pri_grab(p, p->pri); | ||||||
| 					if (p->call_level < SIG_PRI_CALL_LEVEL_PROCEEDING) { | 				if (p->call_level < SIG_PRI_CALL_LEVEL_PROCEEDING) { | ||||||
| 						p->call_level = SIG_PRI_CALL_LEVEL_PROCEEDING; | 					p->call_level = SIG_PRI_CALL_LEVEL_PROCEEDING; | ||||||
| 					} |  | ||||||
| 					pri_proceeding(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 0); |  | ||||||
| 					pri_rel(p->pri); |  | ||||||
| 				} else { |  | ||||||
| 					ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span); |  | ||||||
| 				} | 				} | ||||||
|  | 				pri_proceeding(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 0); | ||||||
|  | 				pri_rel(p->pri); | ||||||
| 			} | 			} | ||||||
| 			sig_pri_unlock_private(p); | 			sig_pri_unlock_private(p); | ||||||
| 		} | 		} | ||||||
| @@ -6580,10 +6577,7 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, i | |||||||
| 		ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd); | 		ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd); | ||||||
| 		return -1; | 		return -1; | ||||||
| 	} | 	} | ||||||
| 	if (pri_grab(p, p->pri)) { | 	pri_grab(p, p->pri); | ||||||
| 		ast_log(LOG_WARNING, "Failed to grab PRI!\n"); |  | ||||||
| 		return -1; |  | ||||||
| 	} |  | ||||||
| 	if (!(p->call = pri_new_call(p->pri->pri))) { | 	if (!(p->call = pri_new_call(p->pri->pri))) { | ||||||
| 		ast_log(LOG_WARNING, "Unable to create call on channel %d\n", p->channel); | 		ast_log(LOG_WARNING, "Unable to create call on channel %d\n", p->channel); | ||||||
| 		pri_rel(p->pri); | 		pri_rel(p->pri); | ||||||
| @@ -6922,16 +6916,13 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi | |||||||
| 			chan->hangupcause = AST_CAUSE_USER_BUSY; | 			chan->hangupcause = AST_CAUSE_USER_BUSY; | ||||||
| 			p->progress = 1;/* No need to send plain PROGRESS after this. */ | 			p->progress = 1;/* No need to send plain PROGRESS after this. */ | ||||||
| 			if (p->pri && p->pri->pri) { | 			if (p->pri && p->pri->pri) { | ||||||
| 				if (!pri_grab(p, p->pri)) { | 				pri_grab(p, p->pri); | ||||||
| #ifdef HAVE_PRI_PROG_W_CAUSE | #ifdef HAVE_PRI_PROG_W_CAUSE | ||||||
| 					pri_progress_with_cause(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 1, chan->hangupcause); | 				pri_progress_with_cause(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 1, chan->hangupcause); | ||||||
| #else | #else | ||||||
| 					pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1); | 				pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1); | ||||||
| #endif | #endif | ||||||
| 					pri_rel(p->pri); | 				pri_rel(p->pri); | ||||||
| 				} else { |  | ||||||
| 					ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span); |  | ||||||
| 				} |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		break; | 		break; | ||||||
| @@ -6939,13 +6930,10 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi | |||||||
| 		if (p->call_level < SIG_PRI_CALL_LEVEL_ALERTING && !p->outgoing) { | 		if (p->call_level < SIG_PRI_CALL_LEVEL_ALERTING && !p->outgoing) { | ||||||
| 			p->call_level = SIG_PRI_CALL_LEVEL_ALERTING; | 			p->call_level = SIG_PRI_CALL_LEVEL_ALERTING; | ||||||
| 			if (p->pri && p->pri->pri) { | 			if (p->pri && p->pri->pri) { | ||||||
| 				if (!pri_grab(p, p->pri)) { | 				pri_grab(p, p->pri); | ||||||
| 					pri_acknowledge(p->pri->pri,p->call, PVT_TO_CHANNEL(p), | 				pri_acknowledge(p->pri->pri,p->call, PVT_TO_CHANNEL(p), | ||||||
| 						p->no_b_channel || p->digital ? 0 : 1); | 					p->no_b_channel || p->digital ? 0 : 1); | ||||||
| 					pri_rel(p->pri); | 				pri_rel(p->pri); | ||||||
| 				} else { |  | ||||||
| 					ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span); |  | ||||||
| 				} |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		res = sig_pri_play_tone(p, SIG_PRI_TONE_RINGTONE); | 		res = sig_pri_play_tone(p, SIG_PRI_TONE_RINGTONE); | ||||||
| @@ -6959,16 +6947,13 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi | |||||||
| 		if (p->call_level < SIG_PRI_CALL_LEVEL_PROCEEDING && !p->outgoing) { | 		if (p->call_level < SIG_PRI_CALL_LEVEL_PROCEEDING && !p->outgoing) { | ||||||
| 			p->call_level = SIG_PRI_CALL_LEVEL_PROCEEDING; | 			p->call_level = SIG_PRI_CALL_LEVEL_PROCEEDING; | ||||||
| 			if (p->pri && p->pri->pri) { | 			if (p->pri && p->pri->pri) { | ||||||
| 				if (!pri_grab(p, p->pri)) { | 				pri_grab(p, p->pri); | ||||||
| 					pri_proceeding(p->pri->pri,p->call, PVT_TO_CHANNEL(p), | 				pri_proceeding(p->pri->pri,p->call, PVT_TO_CHANNEL(p), | ||||||
| 						p->no_b_channel || p->digital ? 0 : 1); | 					p->no_b_channel || p->digital ? 0 : 1); | ||||||
| 					if (!p->no_b_channel && !p->digital) { | 				if (!p->no_b_channel && !p->digital) { | ||||||
| 						sig_pri_set_dialing(p, 0); | 					sig_pri_set_dialing(p, 0); | ||||||
| 					} |  | ||||||
| 					pri_rel(p->pri); |  | ||||||
| 				} else { |  | ||||||
| 					ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span); |  | ||||||
| 				} | 				} | ||||||
|  | 				pri_rel(p->pri); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		/* don't continue in ast_indicate */ | 		/* don't continue in ast_indicate */ | ||||||
| @@ -6981,16 +6966,13 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi | |||||||
| 			&& !p->no_b_channel) { | 			&& !p->no_b_channel) { | ||||||
| 			p->progress = 1;/* No need to send plain PROGRESS again. */ | 			p->progress = 1;/* No need to send plain PROGRESS again. */ | ||||||
| 			if (p->pri && p->pri->pri) { | 			if (p->pri && p->pri->pri) { | ||||||
| 				if (!pri_grab(p, p->pri)) { | 				pri_grab(p, p->pri); | ||||||
| #ifdef HAVE_PRI_PROG_W_CAUSE | #ifdef HAVE_PRI_PROG_W_CAUSE | ||||||
| 					pri_progress_with_cause(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1, -1);  /* no cause at all */ | 				pri_progress_with_cause(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1, -1);  /* no cause at all */ | ||||||
| #else | #else | ||||||
| 					pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1); | 				pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1); | ||||||
| #endif | #endif | ||||||
| 					pri_rel(p->pri); | 				pri_rel(p->pri); | ||||||
| 				} else { |  | ||||||
| 					ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span); |  | ||||||
| 				} |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		/* don't continue in ast_indicate */ | 		/* don't continue in ast_indicate */ | ||||||
| @@ -7037,36 +7019,29 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi | |||||||
| 			} | 			} | ||||||
| 			p->progress = 1;/* No need to send plain PROGRESS after this. */ | 			p->progress = 1;/* No need to send plain PROGRESS after this. */ | ||||||
| 			if (p->pri && p->pri->pri) { | 			if (p->pri && p->pri->pri) { | ||||||
| 				if (!pri_grab(p, p->pri)) { | 				pri_grab(p, p->pri); | ||||||
| #ifdef HAVE_PRI_PROG_W_CAUSE | #ifdef HAVE_PRI_PROG_W_CAUSE | ||||||
| 					pri_progress_with_cause(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 1, chan->hangupcause); | 				pri_progress_with_cause(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 1, chan->hangupcause); | ||||||
| #else | #else | ||||||
| 					pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1); | 				pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1); | ||||||
| #endif | #endif | ||||||
| 					pri_rel(p->pri); | 				pri_rel(p->pri); | ||||||
| 				} else { |  | ||||||
| 					ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span); |  | ||||||
| 				} |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		break; | 		break; | ||||||
| 	case AST_CONTROL_HOLD: | 	case AST_CONTROL_HOLD: | ||||||
| 		if (p->pri && !strcasecmp(p->mohinterpret, "passthrough")) { | 		if (p->pri && !strcasecmp(p->mohinterpret, "passthrough")) { | ||||||
| 			if (!pri_grab(p, p->pri)) { | 			pri_grab(p, p->pri); | ||||||
| 				res = pri_notify(p->pri->pri, p->call, p->prioffset, PRI_NOTIFY_REMOTE_HOLD); | 			res = pri_notify(p->pri->pri, p->call, p->prioffset, PRI_NOTIFY_REMOTE_HOLD); | ||||||
| 				pri_rel(p->pri); | 			pri_rel(p->pri); | ||||||
| 			} else { |  | ||||||
| 				ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span); |  | ||||||
| 			} |  | ||||||
| 		} else | 		} else | ||||||
| 			ast_moh_start(chan, data, p->mohinterpret); | 			ast_moh_start(chan, data, p->mohinterpret); | ||||||
| 		break; | 		break; | ||||||
| 	case AST_CONTROL_UNHOLD: | 	case AST_CONTROL_UNHOLD: | ||||||
| 		if (p->pri && !strcasecmp(p->mohinterpret, "passthrough")) { | 		if (p->pri && !strcasecmp(p->mohinterpret, "passthrough")) { | ||||||
| 			if (!pri_grab(p, p->pri)) { | 			pri_grab(p, p->pri); | ||||||
| 				res = pri_notify(p->pri->pri, p->call, p->prioffset, PRI_NOTIFY_REMOTE_RETRIEVAL); | 			res = pri_notify(p->pri->pri, p->call, p->prioffset, PRI_NOTIFY_REMOTE_RETRIEVAL); | ||||||
| 				pri_rel(p->pri); | 			pri_rel(p->pri); | ||||||
| 			} |  | ||||||
| 		} else | 		} else | ||||||
| 			ast_moh_stop(chan); | 			ast_moh_stop(chan); | ||||||
| 		break; | 		break; | ||||||
| @@ -7078,9 +7053,10 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi | |||||||
| 		break; | 		break; | ||||||
| 	case AST_CONTROL_CONNECTED_LINE: | 	case AST_CONTROL_CONNECTED_LINE: | ||||||
| 		ast_debug(1, "Received AST_CONTROL_CONNECTED_LINE on %s\n", chan->name); | 		ast_debug(1, "Received AST_CONTROL_CONNECTED_LINE on %s\n", chan->name); | ||||||
| 		if (p->pri && !pri_grab(p, p->pri)) { | 		if (p->pri) { | ||||||
| 			struct pri_party_connected_line connected; | 			struct pri_party_connected_line connected; | ||||||
|  |  | ||||||
|  | 			pri_grab(p, p->pri); | ||||||
| 			memset(&connected, 0, sizeof(connected)); | 			memset(&connected, 0, sizeof(connected)); | ||||||
| 			sig_pri_party_id_from_ast(&connected.id, &chan->connected.id); | 			sig_pri_party_id_from_ast(&connected.id, &chan->connected.id); | ||||||
|  |  | ||||||
| @@ -7090,7 +7066,8 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi | |||||||
| 		break; | 		break; | ||||||
| 	case AST_CONTROL_REDIRECTING: | 	case AST_CONTROL_REDIRECTING: | ||||||
| 		ast_debug(1, "Received AST_CONTROL_REDIRECTING on %s\n", chan->name); | 		ast_debug(1, "Received AST_CONTROL_REDIRECTING on %s\n", chan->name); | ||||||
| 		if (p->pri && !pri_grab(p, p->pri)) { | 		if (p->pri) { | ||||||
|  | 			pri_grab(p, p->pri); | ||||||
| 			sig_pri_redirecting_update(p, chan); | 			sig_pri_redirecting_update(p, chan); | ||||||
| 			pri_rel(p->pri); | 			pri_rel(p->pri); | ||||||
| 		} | 		} | ||||||
| @@ -7101,7 +7078,8 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi | |||||||
| 			struct ast_aoc_decoded *decoded | 			struct ast_aoc_decoded *decoded | ||||||
| 				= ast_aoc_decode((struct ast_aoc_encoded *) data, datalen, chan); | 				= ast_aoc_decode((struct ast_aoc_encoded *) data, datalen, chan); | ||||||
| 			ast_debug(1, "Received AST_CONTROL_AOC on %s\n", chan->name); | 			ast_debug(1, "Received AST_CONTROL_AOC on %s\n", chan->name); | ||||||
| 			if (decoded && p->pri && !pri_grab(p, p->pri)) { | 			if (decoded && p->pri) { | ||||||
|  | 				pri_grab(p, p->pri); | ||||||
| 				switch (ast_aoc_get_msg_type(decoded)) { | 				switch (ast_aoc_get_msg_type(decoded)) { | ||||||
| 				case AST_AOC_S: | 				case AST_AOC_S: | ||||||
| 					if (p->pri->aoc_passthrough_flag & SIG_PRI_AOC_GRANT_S) { | 					if (p->pri->aoc_passthrough_flag & SIG_PRI_AOC_GRANT_S) { | ||||||
| @@ -7152,29 +7130,27 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi | |||||||
|  |  | ||||||
| int sig_pri_answer(struct sig_pri_chan *p, struct ast_channel *ast) | int sig_pri_answer(struct sig_pri_chan *p, struct ast_channel *ast) | ||||||
| { | { | ||||||
| 	int res = 0; | 	int res; | ||||||
|  |  | ||||||
| 	/* Send a pri acknowledge */ | 	/* Send a pri acknowledge */ | ||||||
| 	if (!pri_grab(p, p->pri)) { | 	pri_grab(p, p->pri); | ||||||
| #if defined(HAVE_PRI_AOC_EVENTS) | #if defined(HAVE_PRI_AOC_EVENTS) | ||||||
| 		if (p->aoc_s_request_invoke_id_valid) { | 	if (p->aoc_s_request_invoke_id_valid) { | ||||||
| 			/* if AOC-S was requested and the invoke id is still present on answer.  That means | 		/* if AOC-S was requested and the invoke id is still present on answer.  That means | ||||||
| 			 * no AOC-S rate list was provided, so send a NULL response which will indicate that | 		 * no AOC-S rate list was provided, so send a NULL response which will indicate that | ||||||
| 			 * AOC-S is not available */ | 		 * AOC-S is not available */ | ||||||
| 			pri_aoc_s_request_response_send(p->pri->pri, p->call, | 		pri_aoc_s_request_response_send(p->pri->pri, p->call, | ||||||
| 				p->aoc_s_request_invoke_id, NULL); | 			p->aoc_s_request_invoke_id, NULL); | ||||||
| 			p->aoc_s_request_invoke_id_valid = 0; | 		p->aoc_s_request_invoke_id_valid = 0; | ||||||
| 		} |  | ||||||
| #endif	/* defined(HAVE_PRI_AOC_EVENTS) */ |  | ||||||
| 		if (p->call_level < SIG_PRI_CALL_LEVEL_CONNECT) { |  | ||||||
| 			p->call_level = SIG_PRI_CALL_LEVEL_CONNECT; |  | ||||||
| 		} |  | ||||||
| 		sig_pri_set_dialing(p, 0); |  | ||||||
| 		sig_pri_open_media(p); |  | ||||||
| 		res = pri_answer(p->pri->pri, p->call, 0, !p->digital); |  | ||||||
| 		pri_rel(p->pri); |  | ||||||
| 	} else { |  | ||||||
| 		res = -1; |  | ||||||
| 	} | 	} | ||||||
|  | #endif	/* defined(HAVE_PRI_AOC_EVENTS) */ | ||||||
|  | 	if (p->call_level < SIG_PRI_CALL_LEVEL_CONNECT) { | ||||||
|  | 		p->call_level = SIG_PRI_CALL_LEVEL_CONNECT; | ||||||
|  | 	} | ||||||
|  | 	sig_pri_set_dialing(p, 0); | ||||||
|  | 	sig_pri_open_media(p); | ||||||
|  | 	res = pri_answer(p->pri->pri, p->call, 0, !p->digital); | ||||||
|  | 	pri_rel(p->pri); | ||||||
| 	ast_setstate(ast, AST_STATE_UP); | 	ast_setstate(ast, AST_STATE_UP); | ||||||
| 	return res; | 	return res; | ||||||
| } | } | ||||||
| @@ -7315,12 +7291,9 @@ int sig_pri_digit_begin(struct sig_pri_chan *pvt, struct ast_channel *ast, char | |||||||
| 			return 0; | 			return 0; | ||||||
| 		} | 		} | ||||||
| 		if (pvt->call_level < SIG_PRI_CALL_LEVEL_PROCEEDING) { | 		if (pvt->call_level < SIG_PRI_CALL_LEVEL_PROCEEDING) { | ||||||
| 			if (!pri_grab(pvt, pvt->pri)) { | 			pri_grab(pvt, pvt->pri); | ||||||
| 				pri_information(pvt->pri->pri, pvt->call, digit); | 			pri_information(pvt->pri->pri, pvt->call, digit); | ||||||
| 				pri_rel(pvt->pri); | 			pri_rel(pvt->pri); | ||||||
| 			} else { |  | ||||||
| 				ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", pvt->pri->span); |  | ||||||
| 			} |  | ||||||
| 			return 0; | 			return 0; | ||||||
| 		} | 		} | ||||||
| 		if (pvt->call_level < SIG_PRI_CALL_LEVEL_CONNECT) { | 		if (pvt->call_level < SIG_PRI_CALL_LEVEL_CONNECT) { | ||||||
| @@ -7870,14 +7843,9 @@ int pri_send_keypad_facility_exec(struct sig_pri_chan *p, const char *digits) | |||||||
| 		return -1; | 		return -1; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (!pri_grab(p, p->pri)) { | 	pri_grab(p, p->pri); | ||||||
| 		pri_keypad_facility(p->pri->pri, p->call, digits); | 	pri_keypad_facility(p->pri->pri, p->call, digits); | ||||||
| 		pri_rel(p->pri); | 	pri_rel(p->pri); | ||||||
| 	} else { |  | ||||||
| 		ast_debug(1, "Unable to grab pri to send keypad facility!\n"); |  | ||||||
| 		sig_pri_unlock_private(p); |  | ||||||
| 		return -1; |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	sig_pri_unlock_private(p); | 	sig_pri_unlock_private(p); | ||||||
|  |  | ||||||
| @@ -7896,12 +7864,9 @@ int pri_send_callrerouting_facility_exec(struct sig_pri_chan *p, enum ast_channe | |||||||
| 		return -1; | 		return -1; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (!pri_grab(p, p->pri)) { | 	pri_grab(p, p->pri); | ||||||
| 		res = pri_callrerouting_facility(p->pri->pri, p->call, destination, original, reason); | 	res = pri_callrerouting_facility(p->pri->pri, p->call, destination, original, reason); | ||||||
| 		pri_rel(p->pri); | 	pri_rel(p->pri); | ||||||
| 	} else { |  | ||||||
| 		ast_log(LOG_DEBUG, "Unable to grab pri to send callrerouting facility on span %d!\n", p->pri->span); |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	sig_pri_unlock_private(p); | 	sig_pri_unlock_private(p); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user