mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 11:06:31 +00:00
app_dial: Fix progress timeout.
Under some circumstances, the progress timeout feature added in commit320c98eec8
does not work as expected, such as if there is no media flowing. Adjust the waitfor call to explicitly use the progress timeout if it would be reached sooner than the answer timeout to ensure we handle the timers properly. Resolves: #821 (cherry picked from commit97dfe4cd40
)
This commit is contained in:
committed by
Asterisk Development Team
parent
7d8bb3302e
commit
c8d1c29a52
@@ -1214,7 +1214,6 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
||||
struct cause_args num = *num_in;
|
||||
int prestart = num.busy + num.congestion + num.nochan;
|
||||
int orig_answer_to = *to_answer;
|
||||
int progress_to_dup = *to_progress;
|
||||
int orig_progress_to = *to_progress;
|
||||
struct ast_channel *peer = NULL;
|
||||
struct chanlist *outgoing = AST_LIST_FIRST(out_chans);
|
||||
@@ -1259,7 +1258,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
||||
|
||||
is_cc_recall = ast_cc_is_recall(in, &cc_recall_core_id, NULL);
|
||||
|
||||
while ((*to_answer = ast_remaining_ms(start, orig_answer_to)) && (*to_progress = ast_remaining_ms(start, progress_to_dup)) && !peer) {
|
||||
while ((*to_answer = ast_remaining_ms(start, orig_answer_to)) && (*to_progress = ast_remaining_ms(start, orig_progress_to)) && !peer) {
|
||||
struct chanlist *o;
|
||||
int pos = 0; /* how many channels do we handle */
|
||||
int numlines = prestart;
|
||||
@@ -1291,7 +1290,10 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
||||
}
|
||||
SCOPE_EXIT_RTN_VALUE(NULL, "%s: No outgoing channels available\n", ast_channel_name(in));
|
||||
}
|
||||
winner = ast_waitfor_n(watchers, pos, to_answer);
|
||||
|
||||
/* If progress timeout is active, use that if it's the shorter of the 2 timeouts. */
|
||||
winner = ast_waitfor_n(watchers, pos, *to_progress > 0 && *to_progress < *to_answer ? to_progress : to_answer);
|
||||
|
||||
AST_LIST_TRAVERSE(out_chans, o, node) {
|
||||
int res = 0;
|
||||
struct ast_frame *f;
|
||||
@@ -1506,7 +1508,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
||||
*/
|
||||
++num_ringing;
|
||||
*to_progress = -1;
|
||||
progress_to_dup = -1;
|
||||
orig_progress_to = -1;
|
||||
if (ignore_cc || cc_frame_received || num_ringing == numlines) {
|
||||
ast_verb(3, "%s is ringing\n", ast_channel_name(c));
|
||||
/* Setup early media if appropriate */
|
||||
@@ -1551,7 +1553,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
||||
}
|
||||
}
|
||||
*to_progress = -1;
|
||||
progress_to_dup = -1;
|
||||
orig_progress_to = -1;
|
||||
if (!sent_progress) {
|
||||
struct timeval now, then;
|
||||
int64_t diff;
|
||||
@@ -1741,7 +1743,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
||||
break;
|
||||
}
|
||||
*to_progress = -1;
|
||||
progress_to_dup = -1;
|
||||
orig_progress_to = -1;
|
||||
/* Fall through */
|
||||
case AST_FRAME_TEXT:
|
||||
if (single && ast_write(in, f)) {
|
||||
|
Reference in New Issue
Block a user