[MG_Remote, MG_Test] (P7): end a forfeited session whose peer keeps talking on control

This commit is contained in:
2026-09-23 13:44:13 -04:00
parent db4943601f
commit 96ab12b5ab
3 changed files with 48 additions and 8 deletions
+4 -3
View File
@@ -94,9 +94,10 @@ namespace MobileGL::MG_Remote::Client {
// PH-6's fuzz arm 3 ONLY (EventForfeitPeerTest): the control stream, so a peer that has
// stopped draining can still put on it the frames no ClientSession path would send at that
// moment - a malformed one, a surface op queued behind a wait it did not drain for, or a
// half-close. Every production path that writes control holds m_remoteControlMutex and
// drains first; a caller of this does neither, which is the point. Null unless spawned.
// moment - a malformed one, a surface op queued behind a wait it did not drain for, a
// LogFlush every 100 ms, or a half-close. Every production path that writes control holds
// m_remoteControlMutex and drains first; a caller of this does neither, which is the
// point. Null unless spawned.
Transport::SocketTransport* ControlSocketForTest() { return m_socketTransport.get(); }
// CONTRACT-P6 4.3: THE PID THE SERVER STATED IN ITS Welcome, which is not the same fact
+10 -4
View File
@@ -369,18 +369,24 @@ void SendLogAck(void* pointer) {
// later client Busy. Now each quiet interval asks whether the apply thread is still there;
// when it is not (forfeit, or a dead data bell), the session takes the ordinary exit below:
// Stop, Close, _exit(0). The interval is the supervisor's own accept poll.
//
// ASKED AT THE TOP OF EVERY TURN, NOT ONLY WHEN A WAIT TIMES OUT (PH-6 fix round). A peer that
// forfeited the reverse channel but keeps TALKING - a LogFlush or a surface op more often than
// every 250 ms, each of which this loop answers - never let ReceiveFrame time out, so the
// question was never asked and the session, with the supervisor's one slot, lived as long as
// the peer kept chattering.
constexpr std::uint32_t kControlPollMs = 250;
for (;;) {
std::uint64_t size = 0;
const auto result = control->ReceiveFrame({buffer.data(), buffer.size()}, &size, kControlPollMs);
if (result == MOBILEGL_ERR_TIMEOUT) {
if (loop.Running()) continue;
if (!loop.Running()) {
WireLogError("MG_Remote server: pid=%d the apply thread has stopped (%s, %llu event(s) dropped); "
"ending the session",
selfPid, session.ReverseChannelForfeited() ? "ReverseChannelForfeit" : "its bell died",
static_cast<unsigned long long>(session.ForfeitDrops()));
break;
}
std::uint64_t size = 0;
const auto result = control->ReceiveFrame({buffer.data(), buffer.size()}, &size, kControlPollMs);
if (result == MOBILEGL_ERR_TIMEOUT) continue;
if (result == MOBILEGL_ERR_BUFFER_TOO_SMALL) { buffer.resize(static_cast<std::size_t>(size)); continue; }
if (result != MOBILEGL_OK) {
// EOF or a transport error: the peer is gone. Said to the session BEFORE loop.Stop()