imsd: when the client flow is found dead before any response to a call's INVITE, one reconnect and the INVITE again, else the call ends
A flow that is dead in a way imsd has not seen yet, the peer having dropped the connection's state, shows itself at the next bytes sent on it, where the peer answers them with a reset. Where those bytes were an outgoing call's INVITE, imsd read the reset, marked the flow dead and did nothing more for the call: no reconnect runs while a call is up, so the attempt stayed in `dialing` until its setup deadline, 90 s, sent a CANCEL that could not go out and was given up 10 s later, where a call that is no emergency call ends (`setup deadline expired`); the flow was reconnected only once the call was gone. Against a stand-in network that forgets a flow after 20 s of silence, 1.2.3's call ended 100 s after the Dial. The engine's loop now takes such a call up (MaybeResendInvite). When the client flow is found dead under an outgoing attempt whose INVITE has had no response, a 100 included, and no CANCEL, the dead socket is closed without a FIN's exchange, the flow is reopened with one connect and the same INVITE is sent again, the setup deadline running from then. Once per attempt: an emergency call's fallback attempt has a resend of its own. The INVITE is the first one byte for byte, its branch included, so a server that did receive the first matches the second to its transaction (RFC 3261 17.2.3). No REGISTER goes first: the registration and its SAs stand, and TS 33.203 7.1 has a UE with no TCP connection towards the P-CSCF set one up before it sends a request. Where a reg-event NOTIFY has ended the binding nothing is reopened. Where nothing is reopened, the connect fails (one that gets no answer, after 12 s) or the flow dies again before a response, the call ends with `error`, an emergency call's first attempt too: there is no flow for its fallback. The recovery policy takes the flow up once the call is gone, as before. The close without a FIN's exchange is for a flow the peer closed: closed the usual way, such a socket stays in the kernel's table until the peer has acknowledged imsd's own FIN, and a connect from its port before that is refused. A reset goes out in the FIN's place there; after a reset or the kernel's own giving up the socket is closed already and nothing is sent; and the reopen runs on a flow already found dead only. The recovery's reconnect closes the usual way, as before, and connects once more 10 s after such a refusal (one is in a user's log on O2, 2026-09-24, in the second the flow was found dead). Not changed: under a call, a flow that died with no reset and no close reaching the phone is found dead only when the kernel gives up on unacknowledged bytes, 924.6 s or more after them by its default tcp_retries2, so an attempt whose own INVITE is the first such bytes gets no response and is cancelled at its setup deadline, as before; a flow found dead after a response to the INVITE is not reopened, as before; a Dial whose INVITE cannot be sent ends its call at once, as before. Tested: tests/Engine (which attempt is sent again, the same bytes, once per attempt, the deadline anew, the call's end where the flow is lost); the daemon of this commit and 1.2.3's on the workstation against a stand-in network (the fp6 journal's 2026-11-24-crlf-keepalive capture, bench-dial.sh): a flow the network forgot, reopened and the INVITE answered 486 as on a live flow, where 1.2.3's call ended after 100 s; a flow the network closed at the INVITE, with the acknowledgement of the daemon's close kept back; one that died on the daemon's side at the kernel's retransmission limit; a network that takes no new connection, one that resets the second INVITE's flow too and one that has ended the binding, where the call ended within a second; UDP. And on the dev phone on KPN, the binary of the range's tip: a call to voicemail answered and hung up, and one whose flow was made to die under the INVITE before the INVITE left the phone: reopened from the same port, the INVITE again 2.1 s after the death was found, answered 0.2 s later. By a call, no P-CSCF that had dropped a flow's state has been met, and none that had received the first INVITE before the flow died.
This commit is contained in:
parent
d3e495c333
commit
0aea0dac7f
4 changed files with 231 additions and 9 deletions
|
|
@ -470,6 +470,55 @@ int main() {
|
|||
Check(m.Terminated(), "terminated on second timeout");
|
||||
}
|
||||
|
||||
// ---- the client flow dies before any response to the INVITE: the shell
|
||||
// reopens it and the same INVITE goes out again, once per attempt
|
||||
{
|
||||
imsd::util::Rng rng(16);
|
||||
CallMachine m(c, rng, "ims-call-6b", "1233", 50004, false);
|
||||
Check(!m.Unanswered() && !m.ResendDue(), "no INVITE sent yet: nothing to send again");
|
||||
auto start = m.Start();
|
||||
const Action* inv = Sent(start, "INVITE ");
|
||||
Check(m.Unanswered() && m.ResendDue(), "an INVITE with no response: a resend is due");
|
||||
auto again = m.OnFlowReopened();
|
||||
const Action* inv2 = Sent(again, "INVITE ");
|
||||
Check(inv && inv2 && inv2->text == inv->text, "the resent INVITE is the first one, byte for byte");
|
||||
const Action* dl = Find(again, Action::Type::SetDeadline);
|
||||
Check(dl && dl->seconds == imsd::engine::InviteTimeout, "the resend arms the setup deadline anew");
|
||||
Check(m.State() == CallState::Dialing && !m.Terminated(), "still dialing after the resend");
|
||||
Check(m.Unanswered() && !m.ResendDue(), "one resend per attempt");
|
||||
Check(m.OnFlowReopened().empty(), "a second reopen sends nothing");
|
||||
auto lost = m.OnFlowLost();
|
||||
const Action* t = Find(lost, Action::Type::State);
|
||||
Check(t && t->reason == "error" && m.Terminated(), "a flow that dies again ends the call with error");
|
||||
Check(Has(lost, Action::Type::Deleted) && Sent(lost, "CANCEL ") == nullptr, "... deleted, and no CANCEL onto a dead flow");
|
||||
Check(!m.Unanswered() && m.OnFlowLost().empty() && m.OnFlowReopened().empty(), "an ended call has nothing more to end or to send");
|
||||
}
|
||||
|
||||
// ---- ... not once a response has come (a 100 is one), the user has hung
|
||||
// up or a deadline has cancelled the attempt, and never for an
|
||||
// incoming call
|
||||
{
|
||||
imsd::util::Rng rng(17);
|
||||
CallMachine m(c, rng, "ims-call-6c", "1233", 50004, false);
|
||||
m.Start();
|
||||
m.OnInviteResponse(Final(m.CallId(), 100, "Trying"));
|
||||
Check(!m.Unanswered() && !m.ResendDue(), "a 100 Trying is a response: no resend");
|
||||
Check(m.OnFlowReopened().empty() && m.OnFlowLost().empty() && !m.Terminated(), "... and the flow's death is left to the deadline");
|
||||
imsd::util::Rng rng2(18);
|
||||
CallMachine n(c, rng2, "ims-call-6d", "1233", 50004, false);
|
||||
n.Start();
|
||||
n.OnHangup();
|
||||
Check(!n.Unanswered() && n.OnFlowReopened().empty() && n.OnFlowLost().empty(), "an attempt the user cancelled is not sent again");
|
||||
imsd::util::Rng rng3(19);
|
||||
CallMachine o(c, rng3, "ims-call-6e", "1233", 50004, false);
|
||||
o.Start();
|
||||
o.OnDeadline(); // ring timeout: CANCEL
|
||||
Check(!o.Unanswered() && o.OnFlowReopened().empty() && o.OnFlowLost().empty(), "nor one a deadline cancelled");
|
||||
imsd::util::Rng rng4(20);
|
||||
CallMachine p(c, rng4, "ims-call-6f", IncomingInvite{MtInvite()}, 50004);
|
||||
Check(!p.Unanswered() && p.OnFlowReopened().empty() && p.OnFlowLost().empty(), "an incoming call has no INVITE of ours to send again");
|
||||
}
|
||||
|
||||
// ================= incoming (terminating / UAS) =======================
|
||||
|
||||
// ---- full accepted incoming call: INVITE -> 100+180, Accept -> 200 with
|
||||
|
|
@ -880,6 +929,31 @@ int main() {
|
|||
Check(m.State() == CallState::Active, "active on the fallback leg");
|
||||
}
|
||||
|
||||
// ---- the emergency chain with a flow that dies: each attempt has a
|
||||
// resend of its own
|
||||
{
|
||||
imsd::util::Rng rng(44);
|
||||
CallMachine m(c, rng, "ims-call-16b", "112", 50004, false, true);
|
||||
auto start = m.Start();
|
||||
auto again = m.OnFlowReopened();
|
||||
const Action* sos = Sent(start, "INVITE ");
|
||||
const Action* sos2 = Sent(again, "INVITE ");
|
||||
Check(sos && sos2 && sos2->text == sos->text && sos2->text.starts_with("INVITE urn:service:sos "), "the sos INVITE again over a reopened flow");
|
||||
auto a = m.OnInviteResponse(Final(m.CallId(), 500, "Server Internal Error"));
|
||||
const Action* plain = Sent(a, "INVITE ");
|
||||
Check(plain && plain->text.starts_with("INVITE sip:112;phone-context="), "the fallback follows a resent sos attempt as it follows a first one");
|
||||
Check(m.Unanswered() && m.ResendDue(), "the fallback attempt has a resend of its own");
|
||||
auto again2 = m.OnFlowReopened();
|
||||
const Action* plain2 = Sent(again2, "INVITE ");
|
||||
Check(plain && plain2 && plain2->text == plain->text, "... of the fallback's INVITE");
|
||||
imsd::util::Rng rng2(45);
|
||||
CallMachine n(c, rng2, "ims-call-16c", "112", 50004, false, true);
|
||||
n.Start();
|
||||
auto lost = n.OnFlowLost();
|
||||
const Action* t = Find(lost, Action::Type::State);
|
||||
Check(t && t->reason == "error" && n.Terminated() && Sent(lost, "INVITE ") == nullptr, "a sos attempt whose flow is lost ends there: no fallback INVITE onto a dead flow");
|
||||
}
|
||||
|
||||
// ---- chain exhausted: the fallback leg's final terminates, no 3rd try
|
||||
{
|
||||
imsd::util::Rng rng(45);
|
||||
|
|
|
|||
Loading…
Reference in a new issue