Subject: Avoid incorrect re-switching to Ringing after call answered
Bug: https://issues.asterisk.org/view.php?id=17067
Author: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

As described in that bug report, Asterisk seems to insist on trying to set
the state to ringing. It signals that the state needs setting 3 times. And
unfortunately under certain conditions the last one of those gets delayed
in the PCM stream and sets the state to Ringing only after the state was
already set to Up.

diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index f7338ae..a256f23 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -6068,6 +6072,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
 					p->subs[idx].f.frametype = AST_FRAME_CONTROL;
 					p->subs[idx].f.subclass = AST_CONTROL_ANSWER;
 					/* Make sure it stops ringing */
+					p->subs[SUB_REAL].needringing = 0;
 					dahdi_set_hook(p->subs[idx].dfd, DAHDI_OFFHOOK);
 					ast_debug(1, "channel %d answered\n", p->channel);
 					if (p->cidspill) {
