mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-19 16:01:57 +09:00
[MG_Remote, MG_Test, ci] (P7): red-once controls for the latch's decline-and-close half, a control pump that declines after the latch, the pre-gate ahead of the applier's stamp, and a PH-5 raw-peer row that discriminates
This commit is contained in:
@@ -1305,6 +1305,15 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// a short-circuit, which is ID-103's reason extended to the capability probe: they are
|
||||
// exercised on every record for the whole phase rather than first running on the day
|
||||
// they start deciding.
|
||||
//
|
||||
// PH-1 (3): BUT NOT BEFORE THE RECORD HAS BEEN ADMITTED. MGPipeBarriered reads payload
|
||||
// fields (a DrawVbo's MGPDrawInfo::Flags) and the stamps index per-opcode tables, so a
|
||||
// record whose ring header is shorter than its own type - or names no opcode - would be
|
||||
// read past its end here, before DecodeAndApply's pre-gate could refuse it. In an armed
|
||||
// session child the pre-gate therefore runs FIRST: a refused record latches by name and
|
||||
// is declined with nothing stamped (ServerLoopTest's short-record case reads the stamp).
|
||||
// Unarmed it admits everything and the generated gate keeps its death, as before.
|
||||
if (!m_decoder.AdmitOrDecline(record)) return false;
|
||||
const Bool wireSaysBarriered = MG_Pipe::MGPipeBarriered(
|
||||
static_cast<MG_Pipe::MGPWireOp>(record.kind), record.payload, MG_Pipe::MGPipeApplier());
|
||||
MG_Pipe::MGPipeApplierSetCurrentRecordBarriered(
|
||||
|
||||
@@ -430,6 +430,8 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// (and does not spin on a ring whose head is still ahead of a tail DrainRing will no
|
||||
// longer move). The exit path below tears the backend down as for a Stop; the
|
||||
// control connection's owner (ServerMain::RunSession) sees the latch and closes.
|
||||
// Pinned by ServerLoopTest's latched-batch case: without this break the thread is
|
||||
// still running, with no Stop(), three seconds after the latch.
|
||||
if (SessionLatched()) {
|
||||
MGLOG_E("MG_Remote server: mgl-srv-apply leaves its loop - the session latched a "
|
||||
"named fault and declines the rest of the ring (PH-1)");
|
||||
@@ -593,6 +595,7 @@ namespace MobileGL::MG_Remote::Server {
|
||||
if (!m_controlPosted.load(std::memory_order_acquire)) return false;
|
||||
|
||||
SurfaceControlFrame frame;
|
||||
Bool declinedOnLatch = false;
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(m_controlMutex);
|
||||
if (!m_controlPending) {
|
||||
@@ -609,6 +612,23 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// that would act on the shadow is THIS one and it is busy running the frame; leaving
|
||||
// the shadow set would only make the post-work iteration spin instead of park.
|
||||
m_controlPosted.store(false, std::memory_order_release);
|
||||
// PH-1 (3), ID-P7-1: A LATCHED SESSION RUNS NO FURTHER CONTROL OP. A frame can be
|
||||
// posted before the latch and taken after it - RunSession passed SurfaceOpCodec's
|
||||
// latch check a moment before a record latched on this thread, and this thread's
|
||||
// exit path pumps once more - and a MakeCurrent, a surface create or a swap has no
|
||||
// business running on a backend whose session has already been declared over. It
|
||||
// is answered here, without a dispatch, with the code SurfaceOpCodec's own latched
|
||||
// arm gives. ServerLoopTest's post-after-latch case goes red without it.
|
||||
if (SessionLatched()) {
|
||||
m_controlResult = MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||
m_controlPending = false;
|
||||
m_controlFinished = true;
|
||||
declinedOnLatch = true;
|
||||
}
|
||||
}
|
||||
if (declinedOnLatch) {
|
||||
m_controlDone.notify_all();
|
||||
return true;
|
||||
}
|
||||
// The dispatch runs OUTSIDE the lock, exactly as the old work(user) did, and fills the
|
||||
// frame's reply half; the reply is then published back into the slot under the lock so
|
||||
@@ -637,17 +657,25 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// allocation; `applied == 0` then skips the retire block below entirely. Keep it that
|
||||
// way: anything added here runs ~900 times a frame doing nothing.
|
||||
//
|
||||
// PH-1 (3), ID-P7-1: THE LATCH CHECK, AT THE TOP AND BEFORE EVERY POP. Once a named fault
|
||||
// has latched (an armed spawn / TCP session child only - unarmed this is one acquire load
|
||||
// of a flag nobody sets), no further record is applied: the rest of the ring is declined
|
||||
// unread, the apply thread leaves its loop, and RunSession closes the session by name.
|
||||
// PH-1 (3), ID-P7-1: THE LATCH CHECK, TWICE, AND EACH ONE HAS A JOB THE OTHER CANNOT DO.
|
||||
// Once a named fault has latched (an armed spawn / TCP session child only - unarmed this is
|
||||
// one acquire load of a flag nobody sets), no further record is applied: the rest of the
|
||||
// ring is declined unread, the apply thread leaves its loop, and RunSession closes the
|
||||
// session by name.
|
||||
// * HERE, at the top: a drain ENTERED latched pops nothing. That is the apply thread's
|
||||
// exit-path drain after it left on the latch, and any drain after RunSession's thread
|
||||
// latched a control op. ServerLoopTest's latched-batch case goes red without it (the
|
||||
// exit-path drain applies the record behind the latched one).
|
||||
// * AFTER EACH RECORD, at the bottom of the loop: a record that latched is the last one
|
||||
// this drain pops, even when the peer published more behind it in the same batch
|
||||
// (PeerLatchTest's two-record case and ServerLoopTest's latched-batch case).
|
||||
// A check at the loop's head instead would only repeat this one on the first iteration.
|
||||
if (SessionLatched()) return 0;
|
||||
ServerSession& session = *m_session;
|
||||
Transport::SessionConsumer& consumer = session.Consumer();
|
||||
PipeApplier& applier = session.Applier();
|
||||
Uint64 applied = 0;
|
||||
for (;;) {
|
||||
if (SessionLatched()) break;
|
||||
bool corrupt = false;
|
||||
const bool popped = consumer.ApplyOne(
|
||||
[this, &applier](const Transport::RingRecordView& record) {
|
||||
@@ -684,6 +712,8 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// session applies. Checked only AFTER a popped record, so the empty-ring answer above
|
||||
// still costs its two loads and nothing else.
|
||||
if (session.ReverseChannelForfeited()) break;
|
||||
// PH-1 (3): the per-record latch check described at the top of this function.
|
||||
if (SessionLatched()) break;
|
||||
}
|
||||
if (applied != 0) {
|
||||
// THE TWO TALLIES MUST AGREE, AND THAT IS WHAT MAKES R-9's BATCHING BAN CHECKABLE.
|
||||
|
||||
@@ -1576,6 +1576,21 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Bool PipeWireDecoder::AdmitOrDecline(const Transport::RingRecordView& record) {
|
||||
if ((record.flags & Transport::kRecPad) != 0 ||
|
||||
record.kind == Transport::kRingPadRecordKind) {
|
||||
return true; // DecodeAndApply's pad arm names it (R-9)
|
||||
}
|
||||
const Uint64 size = record.payloadSize + sizeof(MGPWireRecHeader);
|
||||
if (AdmitsTheGeneratedGate(static_cast<MGPWireOp>(record.kind), size)) return true;
|
||||
// Latched by name. The record is declined unread and counted, exactly as DecodeAndApply
|
||||
// counts one it declines: the tally is +1 per record whatever became of it.
|
||||
m_resolvedCount = 0;
|
||||
m_lastAcceptanceKnown = false;
|
||||
++m_applySeq;
|
||||
return false;
|
||||
}
|
||||
|
||||
Bool PipeWireDecoder::DecodeAndApply(const Transport::RingRecordView& record) {
|
||||
if (!Valid()) {
|
||||
WireProtocolFatal("PipeWireDecoder::DecodeAndApply", "no control page or segment table");
|
||||
|
||||
@@ -670,6 +670,17 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
// here Fatals, because a pad that reached the decoder has already been counted.
|
||||
Bool DecodeAndApply(const Transport::RingRecordView& record);
|
||||
|
||||
// PH-1 (3): THE PRE-GATE ON ITS OWN, for a caller that reads the record before it hands
|
||||
// it to DecodeAndApply. PipeApplier::ApplyOne stamps the verb boundary and computes
|
||||
// MGPipeBarriered - which reads payload fields (MGPDrawInfo::Flags) - BEFORE the decode,
|
||||
// so a record shorter than its own type, or with an opcode no row names, has to be refused
|
||||
// ahead of that read, not only inside DecodeAndApply. True: the record may be read (and
|
||||
// DecodeAndApply asks the same questions again, with the same answer). False: an armed
|
||||
// session child latched it by name, and it is COUNTED here as a declined record so this
|
||||
// decoder's tally stays level with appliedSeq (R-9). Unarmed it always answers true: the
|
||||
// generated gate keeps its own death. A pad is let through for DecodeAndApply's own arm.
|
||||
Bool AdmitOrDecline(const Transport::RingRecordView& record);
|
||||
|
||||
// THE DECODER'S OWN TALLY, NOT THE SHARED WATERMARK. Advanced by exactly one per
|
||||
// applied non-pad record.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user