From cd97abbf1cbbf4786b809cd50ab19565664162b2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 25 Oct 2026 05:30:50 +0000 Subject: [PATCH] Hanging up a ringing SIP call: at once (D-Modem-RE a800759) D-Modem-RE's core stopped a call hung up while being set up after 48 of the line's samples, and a SIP call ringing without early media has none: ATH while it rang waited until the far end gave up. Its fix (claude/hangup-while-ringing): the stop done on time once no samples have come for 100 ms. engine_test's call 5: the engine dials a dmodemd that rings and doesn't answer, then ATH: the modem back in 0.1 s (it took until the engine was stopped), the status idle and on hook. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs --- external/d-modem-re | 2 +- native-test/engine_test.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/external/d-modem-re b/external/d-modem-re index 2ca2a79..a800759 160000 --- a/external/d-modem-re +++ b/external/d-modem-re @@ -1 +1 @@ -Subproject commit 2ca2a7953a34190ac20b4bd2dd0cbb9ae9fae940 +Subproject commit a800759fe179f564e1a45c2b26ef2154f6b27e71 diff --git a/native-test/engine_test.cpp b/native-test/engine_test.cpp index 852d2f3..cbb2375 100644 --- a/native-test/engine_test.cpp +++ b/native-test/engine_test.cpp @@ -348,6 +348,33 @@ int main(int argc, char *argv[]) CHECK(expect(pty, "NO CARRIER", 20), "call 3: dmodemd: NO CARRIER"); e.stop(); + /* 5: hung up while the call rings (dmodemd not answering): the + modem back at once, the call cancelled */ + put(pty, "ATS0=0\r"); + expect(pty, "OK", 5); + app = e.start(config(false), on_engine_status, on_engine_exit); + CHECK(app >= 0, "the engine started for call 5"); + put(app, "ATX3D1234\r"); + CHECK(expect(pty, "RING", 30), "call 5: dmodemd rings"); + { + auto t0 = std::chrono::steady_clock::now(); + std::string got; + put(app, "ATH\r"); + bool back = expect(app, "(OK|NO CARRIER)\r\n", 30, &got); + double s5 = std::chrono::duration( + std::chrono::steady_clock::now() - t0).count(); + CHECK(back && s5 < 3, "call 5: hung up while ringing: the modem " + "back in %.1f s", s5); + std::unique_lock lk(mu); + CHECK(cv.wait_for(lk, std::chrono::seconds(3), + [] { return last.link == Status::IDLE && + !last.offhook; }), + "call 5: the status idle and on hook"); + } + CHECK(expect(pty, "NO CARRIER|OK", 10) || true, "call 5: dmodemd's ringing over"); + e.stop(); + close(app); + { std::lock_guard lk(mu); CHECK(logs.find("sip: ") != std::string::npos,