summaryrefslogtreecommitdiff
path: root/channels/sig_pri.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2011-11-17 17:31:16 +0000
committerRichard Mudgett <rmudgett@digium.com>2011-11-17 17:31:16 +0000
commit4a125f45a0e6bb2a6c71265521834ef3dd1972cd (patch)
tree5800461a68ee8655b2354dff5491127c346a1cc5 /channels/sig_pri.c
parent2d67b1b37878a799be9716de2ed1087a5687ac58 (diff)
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 ........ Merged revisions 345558 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@345559 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/sig_pri.c')
-rw-r--r--channels/sig_pri.c173
1 files changed, 68 insertions, 105 deletions
diff --git a/channels/sig_pri.c b/channels/sig_pri.c
index c9948e0c3..e0e40725c 100644
--- a/channels/sig_pri.c
+++ b/channels/sig_pri.c
@@ -331,9 +331,10 @@ static void sig_pri_deadlock_avoidance_private(struct sig_pri_chan *p)
}
}
-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 @@ static inline int pri_grab(struct sig_pri_chan *p, struct sig_pri_span *pri)
} while (res);
/* Then break the poll */
pthread_kill(pri->master, SIGURG);
- return 0;
}
/*!
@@ -1936,15 +1936,12 @@ static void *pri_ss_thread(void *data)
&& !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 @@ 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);
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 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi
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 @@ 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) {
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 @@ 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) {
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 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi
&& !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 @@ 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. */
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 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi
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 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi
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 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi
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 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi
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_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 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 @@ int sig_pri_digit_begin(struct sig_pri_chan *pvt, struct ast_channel *ast, char
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 @@ int pri_send_keypad_facility_exec(struct sig_pri_chan *p, const char *digits)
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 @@ int pri_send_callrerouting_facility_exec(struct sig_pri_chan *p, enum ast_channe
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);