[asterisk-commits] rmudgett: branch 10 r345558 - in /branches/10: ./ channels/sig_pri.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Nov 17 11:29:20 CST 2011


Author: rmudgett
Date: Thu Nov 17 11:29:16 2011
New Revision: 345558

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=345558
Log:
Remove dead code since pri_grab() can never fail.

Dead code makes programmers sick.  I am sick of looking at it.
........

Merged revisions 345546 from http://svn.asterisk.org/svn/asterisk/branches/1.8

Modified:
    branches/10/   (props changed)
    branches/10/channels/sig_pri.c

Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/10/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/channels/sig_pri.c?view=diff&rev=345558&r1=345557&r2=345558
==============================================================================
--- branches/10/channels/sig_pri.c (original)
+++ branches/10/channels/sig_pri.c Thu Nov 17 11:29:16 2011
@@ -331,9 +331,10 @@
 	}
 }
 
-static inline int pri_grab(struct sig_pri_chan *p, struct sig_pri_span *pri)
+static void pri_grab(struct sig_pri_chan *p, struct sig_pri_span *pri)
 {
 	int res;
+
 	/* Grab the lock first */
 	do {
 		res = ast_mutex_trylock(&pri->lock);
@@ -343,7 +344,6 @@
 	} while (res);
 	/* Then break the poll */
 	pthread_kill(pri->master, SIGURG);
-	return 0;
 }
 
 /*!
@@ -1936,15 +1936,12 @@
 			&& !ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) {
 			sig_pri_lock_private(p);
 			if (p->pri->pri) {
-				if (!pri_grab(p, p->pri)) {
-					if (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_grab(p, p->pri);
+				if (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);
 			}
 			sig_pri_unlock_private(p);
 		}
@@ -7480,10 +7477,7 @@
 		ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd);
 		return -1;
 	}
-	if (pri_grab(p, p->pri)) {
-		ast_log(LOG_WARNING, "Failed to grab PRI!\n");
-		return -1;
-	}
+	pri_grab(p, p->pri);
 	if (!(p->call = pri_new_call(p->pri->pri))) {
 		ast_log(LOG_WARNING, "Unable to create call on channel %d\n", p->channel);
 		pri_rel(p->pri);
@@ -7825,16 +7819,13 @@
 			chan->hangupcause = AST_CAUSE_USER_BUSY;
 			p->progress = 1;/* No need to send plain PROGRESS after this. */
 			if (p->pri && p->pri->pri) {
-				if (!pri_grab(p, p->pri)) {
+				pri_grab(p, p->pri);
 #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
-					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
-					pri_rel(p->pri);
-				} else {
-					ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span);
-				}
+				pri_rel(p->pri);
 			}
 		}
 		break;
@@ -7842,13 +7833,10 @@
 		if (p->call_level < SIG_PRI_CALL_LEVEL_ALERTING && !p->outgoing) {
 			p->call_level = SIG_PRI_CALL_LEVEL_ALERTING;
 			if (p->pri && p->pri->pri) {
-				if (!pri_grab(p, p->pri)) {
-					pri_acknowledge(p->pri->pri,p->call, PVT_TO_CHANNEL(p),
-						p->no_b_channel || p->digital ? 0 : 1);
-					pri_rel(p->pri);
-				} else {
-					ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span);
-				}
+				pri_grab(p, p->pri);
+				pri_acknowledge(p->pri->pri,p->call, PVT_TO_CHANNEL(p),
+					p->no_b_channel || p->digital ? 0 : 1);
+				pri_rel(p->pri);
 			}
 		}
 		res = sig_pri_play_tone(p, SIG_PRI_TONE_RINGTONE);
@@ -7862,16 +7850,13 @@
 		if (p->call_level < SIG_PRI_CALL_LEVEL_PROCEEDING && !p->outgoing) {
 			p->call_level = SIG_PRI_CALL_LEVEL_PROCEEDING;
 			if (p->pri && p->pri->pri) {
-				if (!pri_grab(p, p->pri)) {
-					pri_proceeding(p->pri->pri,p->call, PVT_TO_CHANNEL(p),
-						p->no_b_channel || p->digital ? 0 : 1);
-					if (!p->no_b_channel && !p->digital) {
-						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_grab(p, p->pri);
+				pri_proceeding(p->pri->pri,p->call, PVT_TO_CHANNEL(p),
+					p->no_b_channel || p->digital ? 0 : 1);
+				if (!p->no_b_channel && !p->digital) {
+					sig_pri_set_dialing(p, 0);
+				}
+				pri_rel(p->pri);
 			}
 		}
 		/* don't continue in ast_indicate */
@@ -7884,16 +7869,13 @@
 			&& !p->no_b_channel) {
 			p->progress = 1;/* No need to send plain PROGRESS again. */
 			if (p->pri && p->pri->pri) {
-				if (!pri_grab(p, p->pri)) {
+				pri_grab(p, p->pri);
 #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
-					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
-					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 */
@@ -7940,28 +7922,22 @@
 			}
 			p->progress = 1;/* No need to send plain PROGRESS after this. */
 			if (p->pri && p->pri->pri) {
-				if (!pri_grab(p, p->pri)) {
+				pri_grab(p, p->pri);
 #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
-					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
-					pri_rel(p->pri);
-				} else {
-					ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span);
-				}
+				pri_rel(p->pri);
 			}
 		}
 		break;
 	case AST_CONTROL_HOLD:
 		ast_copy_string(p->moh_suggested, S_OR(data, ""), sizeof(p->moh_suggested));
 		if (p->pri) {
-			if (!pri_grab(p, p->pri)) {
-				sig_pri_moh_fsm_event(chan, p, SIG_PRI_MOH_EVENT_HOLD);
-				pri_rel(p->pri);
-			} else {
-				ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span);
-			}
+			pri_grab(p, p->pri);
+			sig_pri_moh_fsm_event(chan, p, SIG_PRI_MOH_EVENT_HOLD);
+			pri_rel(p->pri);
 		} else {
 			/* Something is wrong here.  A PRI channel without the pri pointer? */
 			ast_moh_start(chan, data, p->mohinterpret);
@@ -7969,12 +7945,9 @@
 		break;
 	case AST_CONTROL_UNHOLD:
 		if (p->pri) {
-			if (!pri_grab(p, p->pri)) {
-				sig_pri_moh_fsm_event(chan, p, SIG_PRI_MOH_EVENT_UNHOLD);
-				pri_rel(p->pri);
-			} else {
-				ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span);
-			}
+			pri_grab(p, p->pri);
+			sig_pri_moh_fsm_event(chan, p, SIG_PRI_MOH_EVENT_UNHOLD);
+			pri_rel(p->pri);
 		} else {
 			/* Something is wrong here.  A PRI channel without the pri pointer? */
 			ast_moh_stop(chan);
@@ -7988,11 +7961,12 @@
 		break;
 	case AST_CONTROL_CONNECTED_LINE:
 		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;
 			int dialplan;
 			int prefix_strip;
 
+			pri_grab(p, p->pri);
 			memset(&connected, 0, sizeof(connected));
 			sig_pri_party_id_from_ast(&connected.id, &chan->connected.id);
 
@@ -8036,7 +8010,8 @@
 		break;
 	case AST_CONTROL_REDIRECTING:
 		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);
 			pri_rel(p->pri);
 		}
@@ -8047,7 +8022,8 @@
 			struct ast_aoc_decoded *decoded
 				= ast_aoc_decode((struct ast_aoc_encoded *) data, datalen, chan);
 			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)) {
 				case AST_AOC_S:
 					if (p->pri->aoc_passthrough_flag & SIG_PRI_AOC_GRANT_S) {
@@ -8107,29 +8083,27 @@
 
 int sig_pri_answer(struct sig_pri_chan *p, struct ast_channel *ast)
 {
-	int res = 0;
+	int res;
+
 	/* Send a pri acknowledge */
-	if (!pri_grab(p, p->pri)) {
+	pri_grab(p, p->pri);
 #if defined(HAVE_PRI_AOC_EVENTS)
-		if (p->aoc_s_request_invoke_id_valid) {
-			/* 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
-			 * AOC-S is not available */
-			pri_aoc_s_request_response_send(p->pri->pri, p->call,
-				p->aoc_s_request_invoke_id, NULL);
-			p->aoc_s_request_invoke_id_valid = 0;
-		}
+	if (p->aoc_s_request_invoke_id_valid) {
+		/* 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
+		 * AOC-S is not available */
+		pri_aoc_s_request_response_send(p->pri->pri, p->call,
+			p->aoc_s_request_invoke_id, NULL);
+		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;
-	}
+	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);
 	return res;
 }
@@ -8270,12 +8244,9 @@
 			return 0;
 		}
 		if (pvt->call_level < SIG_PRI_CALL_LEVEL_PROCEEDING) {
-			if (!pri_grab(pvt, pvt->pri)) {
-				pri_information(pvt->pri->pri, pvt->call, digit);
-				pri_rel(pvt->pri);
-			} else {
-				ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", pvt->pri->span);
-			}
+			pri_grab(pvt, pvt->pri);
+			pri_information(pvt->pri->pri, pvt->call, digit);
+			pri_rel(pvt->pri);
 			return 0;
 		}
 		if (pvt->call_level < SIG_PRI_CALL_LEVEL_CONNECT) {
@@ -8882,14 +8853,9 @@
 		return -1;
 	}
 
-	if (!pri_grab(p, p->pri)) {
-		pri_keypad_facility(p->pri->pri, p->call, digits);
-		pri_rel(p->pri);
-	} else {
-		ast_debug(1, "Unable to grab pri to send keypad facility!\n");
-		sig_pri_unlock_private(p);
-		return -1;
-	}
+	pri_grab(p, p->pri);
+	pri_keypad_facility(p->pri->pri, p->call, digits);
+	pri_rel(p->pri);
 
 	sig_pri_unlock_private(p);
 
@@ -8908,12 +8874,9 @@
 		return -1;
 	}
 
-	if (!pri_grab(p, p->pri)) {
-		res = pri_callrerouting_facility(p->pri->pri, p->call, destination, original, reason);
-		pri_rel(p->pri);
-	} else {
-		ast_debug(1, "Unable to grab pri to send callrerouting facility on span %d!\n", p->pri->span);
-	}
+	pri_grab(p, p->pri);
+	res = pri_callrerouting_facility(p->pri->pri, p->call, destination, original, reason);
+	pri_rel(p->pri);
 
 	sig_pri_unlock_private(p);
 




More information about the asterisk-commits mailing list