mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-18 15:33:22 +09:00
[Fix] (P11 A1): settle MOBILEGL_IPC_ADOPT_TIER at the handshake from the data plane - a stream refuses T0/T1 by name and runs T2 on either side, a client over shared segments dies by name before any record, the at-use check trusts the settlement; unit gates on a real tcp session and a real inproc handshake
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "../Server/ServerLoop.h"
|
||||
#include "../Server/ServerSession.h"
|
||||
#include "../Protocol/SurfaceOpCodec.h"
|
||||
#include "../Transport/AdoptTier.h"
|
||||
#include "../Transport/FdPassing.h"
|
||||
#include "../Transport/InProcessTransport.h"
|
||||
#include "WireTables.h"
|
||||
@@ -790,6 +791,11 @@ namespace MobileGL::MG_Remote::Client {
|
||||
Stop();
|
||||
return result;
|
||||
}
|
||||
// P11 A1: the adopt tier, settled by the side that holds the knob once the link terms
|
||||
// say which plane this is (inproc is shared segments by construction), before any
|
||||
// record. T0/T1 over shared segments die here by name (Transport/AdoptTier.h).
|
||||
(void)Transport::SettleAdoptTierAtHandshake(
|
||||
terms->dataPlane() == ::MobileGL::Wire::DataPlane::Stream, Transport::AdoptTierSide::Client);
|
||||
// The four SegmentRefs are what a spawn client MAPS (P6). Under inproc the mapping
|
||||
// already exists, so what they are good for here is the cross-check that the two
|
||||
// sides agree about the geometry at all - which is the assertion that would
|
||||
@@ -1026,6 +1032,10 @@ namespace MobileGL::MG_Remote::Client {
|
||||
return result;
|
||||
}
|
||||
stream = terms->dataPlane() == ::MobileGL::Wire::DataPlane::Stream;
|
||||
// P11 A1: as in StartOverTransportPair - the knob against the plane the link terms
|
||||
// settled, before the data connection and before any record. A stream refuses T0/T1
|
||||
// by name and runs T2; shared segments die here by name (Transport/AdoptTier.h).
|
||||
(void)Transport::SettleAdoptTierAtHandshake(stream, Transport::AdoptTierSide::Client);
|
||||
if (stream) {
|
||||
// PH-7 (4). A Stream Welcome without a nonce of exactly the minted width names no
|
||||
// data connection this client could open; refused rather than guessed at.
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "PersistentMapTracker.h"
|
||||
#include <MG_Remote/FatalFunnel.h>
|
||||
#include <MG_Remote/Transport/AdoptTier.h>
|
||||
|
||||
#include <MG_Pipe/MGPipeTypes.h>
|
||||
#include <MG_State/GLState/BufferState/BufferObject.h>
|
||||
@@ -1246,27 +1247,23 @@ namespace MobileGL::MG_Remote::Client {
|
||||
Bool AdoptTierIsEmulate() {
|
||||
const Uint32 tier = MG_Config::Ipc.AdoptTier;
|
||||
if (tier == 2) return true;
|
||||
// A NAMED refusal, not a silent fall back to T2. T0 (a real cross-process shared
|
||||
// mapping) and T1 (a server-side staging map) are P11's, and the reason the knob
|
||||
// parses them today is that the negative control needs a spelling before the thing
|
||||
// it controls exists. Falling back would make `MOBILEGL_IPC_ADOPT_TIER=0` look like
|
||||
// a working T0 run and silently produce pmap bytes it must not produce.
|
||||
// 0 and 1 are the two CONTRACT §5 promises - a real cross-process shared mapping and a
|
||||
// server-side staging map - and they name P11. Anything else is not a tier at all, and
|
||||
// saying "P11 implements it" of a 7 would be a lie the operator then repeats. Both die
|
||||
// here rather than at parse, which is late: the abort lands at the first
|
||||
// map_persistent, so a mis-set run gets through EGL bring-up and a frame of setup
|
||||
// first. Moving it to the parse means a knob-validity rule in ConfigLoader, which is
|
||||
// c0's file; filed for the integrator rather than taken here.
|
||||
// `dl` (CONTRACT-P6 5.2): THE FAMILY WORD THIS SITE NEVER CARRIED. a6 found two aborts
|
||||
// under MG_Remote/ with no Fatal{ marker at all, so "the log stays verbatim" was not true
|
||||
// of them and no family grep could see them - this is one. (The other, WireLog.cpp's, is
|
||||
// the sanctioned funnel: every one of its callers passes a Fatal{ string of its own.)
|
||||
// P11 A1 (CONTRACT-P11 §1): THE VERDICT IS THE HANDSHAKE'S, NOT THIS CALL'S. Both roles
|
||||
// settle the tier from the knob and the data plane before the first record
|
||||
// (Transport/AdoptTier.cpp): a stream refuses T0/T1 by name and runs T2, a client over
|
||||
// shared segments dies by name there, and a server over shared segments serves the T2
|
||||
// its client settled. So a settled session reaching this with 0/1 is a T2 session and
|
||||
// says nothing more - the one line was the handshake's.
|
||||
if (tier <= 1 && Transport::AdoptTierSettledAtHandshake()) return true;
|
||||
// A map_persistent NO handshake settled (a session-free caller) is still a NAMED
|
||||
// refusal rather than a silent T2: falling back would make `MOBILEGL_IPC_ADOPT_TIER=0`
|
||||
// look like a working T0 run and silently produce pmap bytes it must not produce.
|
||||
// Anything above 2 is not a tier at all.
|
||||
// `dl` (CONTRACT-P6 5.2): the family word every death here carries.
|
||||
if (tier <= 1) {
|
||||
SessionFail(MGFatalFamily::UnimplementedAdoptTier,
|
||||
"MGPipe: Fatal{UnimplementedAdoptTier, \"T%u\"} - MOBILEGL_IPC_ADOPT_TIER=%u "
|
||||
"names an adoption tier P11 implements and P5 does not; P5 runs at T2 "
|
||||
"(emulate) only.",
|
||||
"reached a map_persistent that no handshake settled; T0 and T1 are not "
|
||||
"implemented and only T2 (emulate) runs.",
|
||||
static_cast<unsigned>(tier), static_cast<unsigned>(tier));
|
||||
} else {
|
||||
SessionFail(MGFatalFamily::UnimplementedAdoptTier,
|
||||
|
||||
@@ -268,10 +268,13 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// draw-path binding walks move to the client.
|
||||
void PushPersistentMapsBeforeVerb();
|
||||
|
||||
// R-6's tier gate, and the ONE spelling of it. True for MOBILEGL_IPC_ADOPT_TIER=2, the
|
||||
// only tier P5 implements; 0 (a real cross-process shared mapping) and 1 (a server-side
|
||||
// staging map) parse - so the negative control has a name before the thing it controls
|
||||
// exists - and are a NAMED refusal here rather than a silent fall back to T2. It is asked
|
||||
// R-6's tier gate, read at use. True for MOBILEGL_IPC_ADOPT_TIER=2, the only implemented
|
||||
// tier. The tiers are design/07's: T0 = the client allocates an AHardwareBuffer and the
|
||||
// server imports it (P11 package B), T1 = the server exports an opaque fd (closed), T2 =
|
||||
// decline and push. 0 and 1 are SETTLED AT THE HANDSHAKE (P11 A1, Transport/AdoptTier.h):
|
||||
// a stream refuses them by name and runs T2, a client over shared segments dies by name
|
||||
// there. So a settled session answers true here; only a map_persistent no handshake
|
||||
// settled is still a named refusal. It is asked
|
||||
// by MGPipeApplyMapPersistent, which is where the decline is decided, so the client's
|
||||
// three adoption call sites keep their existing "null means declined" branch and the
|
||||
// map-persistent-roundtrips counter keeps counting ATTEMPTS in both arms (E3(c) asserts
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "../CapsCodec.h"
|
||||
#include "../Handshake.h"
|
||||
#include "../Transport/LinkMetrics.h"
|
||||
#include "../Transport/AdoptTier.h"
|
||||
#include "../Protocol/generated/protocol_generated.h"
|
||||
#include "../Transport/InProcessTransport.h"
|
||||
|
||||
@@ -673,6 +674,11 @@ namespace MobileGL::MG_Remote::Server {
|
||||
"backend request differs from server", m_backend == nullptr ? 0 :
|
||||
static_cast<Uint32>(m_backend->GetBackendType()), hello->backendType());
|
||||
|
||||
// ---- P11 A1: this side's adopt tier, from its own knob and the plane the Hello asked
|
||||
// for, before a byte of Welcome. A stream refuses T0/T1 by name and serves T2; over
|
||||
// shared segments the client settles it (Transport/AdoptTier.h). 0/1 never die here.
|
||||
(void)Transport::SettleAdoptTierAtHandshake(stream, Transport::AdoptTierSide::Server);
|
||||
|
||||
// ---- 3. the four segments, both control pages, the rings.
|
||||
MobileGLResult created = MOBILEGL_ERR_UNSUPPORTED;
|
||||
// PH-7 (4), ID-P7-3. Minted HERE - after the token was checked, before a byte of Welcome
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
// MobileGL - MobileGL/MG_Remote/Transport/AdoptTier.cpp
|
||||
// Copyright (c) 2025-2026 MobileGL-Dev
|
||||
// Licensed under the GNU Lesser General Public License v3.0:
|
||||
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// End of Source File Header
|
||||
|
||||
#include "AdoptTier.h"
|
||||
|
||||
#include <Config.h>
|
||||
#include <MG_Remote/FatalFunnel.h>
|
||||
#include <MG_Util/Debug/Log.h>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
namespace MobileGL::MG_Remote::Transport {
|
||||
|
||||
namespace {
|
||||
std::atomic<bool> g_settled{false};
|
||||
|
||||
const char* SideName(AdoptTierSide side) { return side == AdoptTierSide::Client ? "client" : "server"; }
|
||||
} // namespace
|
||||
|
||||
std::uint32_t SettleAdoptTierAtHandshake(bool streamDataPlane, AdoptTierSide side) {
|
||||
const std::uint32_t knob = MG_Config::Ipc.AdoptTier;
|
||||
if (knob > 2) {
|
||||
// Unreachable through ConfigLoader (it admits 0..2); a direct assignment is the only
|
||||
// way here, and "P11 implements it" of a 7 would be a lie.
|
||||
SessionFail(MGFatalFamily::UnimplementedAdoptTier,
|
||||
"MGPipe: Fatal{UnimplementedAdoptTier, \"%u\"} - MOBILEGL_IPC_ADOPT_TIER=%u is not an "
|
||||
"adoption tier; the values are 0 and 1 (not implemented) and 2 (emulate, the default)",
|
||||
static_cast<unsigned>(knob), static_cast<unsigned>(knob));
|
||||
}
|
||||
if (knob == 2) {
|
||||
g_settled.store(true, std::memory_order_release);
|
||||
return 2;
|
||||
}
|
||||
if (streamDataPlane) {
|
||||
// ONE LINE PER SESSION, on the side that holds the knob. The tcp lane's server is a
|
||||
// shared fixture that never sees the client's environment, so each side says it for
|
||||
// itself; neither side dies, because T2 is the only tier a stream can carry.
|
||||
MGLOG_W("MG_Remote %s: Refuse{AdoptTierOnStream, \"T%u\"} - MOBILEGL_IPC_ADOPT_TIER=%u names a "
|
||||
"shared-mapping adoption tier and this session's data plane is a stream (tcp): the two "
|
||||
"sides share no memory to map, so the session runs T2 (emulate: the client keeps the "
|
||||
"shadow and pushes)",
|
||||
SideName(side), static_cast<unsigned>(knob), static_cast<unsigned>(knob));
|
||||
g_settled.store(true, std::memory_order_release);
|
||||
return 2;
|
||||
}
|
||||
if (side == AdoptTierSide::Server) {
|
||||
MGLOG_W("MG_Remote server: MOBILEGL_IPC_ADOPT_TIER=%u is the client's to settle on a shared-segment "
|
||||
"link (a client naming T0/T1 dies by name at its own handshake); this server serves T2",
|
||||
static_cast<unsigned>(knob));
|
||||
g_settled.store(true, std::memory_order_release);
|
||||
return 2;
|
||||
}
|
||||
SessionFail(MGFatalFamily::UnimplementedAdoptTier,
|
||||
"MGPipe: Fatal{UnimplementedAdoptTier, \"T%u\"} - MOBILEGL_IPC_ADOPT_TIER=%u names a "
|
||||
"shared-mapping adoption tier no package implements yet (T0 is P11 package B's, T1 is "
|
||||
"closed); refused at the handshake over shared segments, before any record is emitted. "
|
||||
"Unset it or set 2 (emulate)",
|
||||
static_cast<unsigned>(knob), static_cast<unsigned>(knob));
|
||||
}
|
||||
|
||||
bool AdoptTierSettledAtHandshake() { return g_settled.load(std::memory_order_acquire); }
|
||||
|
||||
void ForgetAdoptTierSettlementForTest() { g_settled.store(false, std::memory_order_release); }
|
||||
|
||||
} // namespace MobileGL::MG_Remote::Transport
|
||||
@@ -0,0 +1,53 @@
|
||||
// MobileGL - MobileGL/MG_Remote/Transport/AdoptTier.h
|
||||
// Copyright (c) 2025-2026 MobileGL-Dev
|
||||
// Licensed under the GNU Lesser General Public License v3.0:
|
||||
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// End of Source File Header
|
||||
|
||||
// P11 A1 (MG_Remote/CONTRACT-P11.md §1): THE PERSISTENT-MAP ADOPTION TIER IS SETTLED AT THE
|
||||
// HANDSHAKE, BY THE SIDE THAT KNOWS THE DATA PLANE, BEFORE THE FIRST map_persistent.
|
||||
//
|
||||
// Tier names follow docs/Disaggregated/design/07: T0 = the client allocates an AHardwareBuffer
|
||||
// and the server imports it; T1 = the server exports an opaque fd; T2 = the resource owner
|
||||
// declines and the client keeps the shadow and pushes. Only T2 is implemented (T0 is P11
|
||||
// package B's, T1 is closed), so MOBILEGL_IPC_ADOPT_TIER=0/1 is either refused by name or
|
||||
// fatal - never a silent T2, and never discovered at the first map_persistent:
|
||||
//
|
||||
// data plane side knob 0 / 1
|
||||
// Stream (tcp) either one line `Refuse{AdoptTierOnStream, "T<n>"}`, then T2. Never Fatal:
|
||||
// a stream has no memory the two sides share, so no tier but T2
|
||||
// can exist on it.
|
||||
// SharedSegments client Fatal{UnimplementedAdoptTier, "T<n>"} at the handshake, before any
|
||||
// record is emitted.
|
||||
// SharedSegments server one warning that the client settles the tier on this plane, then
|
||||
// T2. (inproc and fork share the client's environment, so the client
|
||||
// dies by name right after; a unix-socket server launched on its own
|
||||
// serves the T2 its client settled.)
|
||||
//
|
||||
// In MG_Remote/Transport (the link-ratchet's SERVER partition) because both roles call it:
|
||||
// ServerSession::Accept and ClientSession's two Start halves. The at-use check the server's
|
||||
// applier and codec ask (Client::AdoptTierIsEmulate) reads the settlement back.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace MobileGL::MG_Remote::Transport {
|
||||
|
||||
enum class AdoptTierSide : std::uint8_t { Client, Server };
|
||||
|
||||
// Settles this session's tier from MOBILEGL_IPC_ADOPT_TIER and the negotiated data plane,
|
||||
// on `side`, and returns the tier the session runs (2 until package B). Logs at most one
|
||||
// line per call; aborts (SessionFail) only on the client over shared segments.
|
||||
std::uint32_t SettleAdoptTierAtHandshake(bool streamDataPlane, AdoptTierSide side);
|
||||
|
||||
// True once a handshake in this process has settled the tier. The at-use check trusts a
|
||||
// settled session and still refuses by name a map_persistent no handshake settled.
|
||||
bool AdoptTierSettledAtHandshake();
|
||||
|
||||
// Test seam: forget the settlement, so one process can drive both answers.
|
||||
void ForgetAdoptTierSettlementForTest();
|
||||
|
||||
} // namespace MobileGL::MG_Remote::Transport
|
||||
@@ -1840,10 +1840,11 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
// used to decline UNCONDITIONALLY and AdoptTier had no reference anywhere on the
|
||||
// codec path, so MOBILEGL_IPC_ADOPT_TIER=0 and =1 - which contract §5 promises
|
||||
// "parse and are Fatal at use, naming P11" - decoded as an ordinary DECLINED and
|
||||
// the operator got a run that looked like a working T0. AdoptTierIsEmulate returns
|
||||
// true at T2 and ABORTS at T0/T1 on its own named diagnostic, so the return value
|
||||
// is deliberately not a branch: P5 declines at every tier it survives (R-6), and
|
||||
// the two forbidden ones never get this far.
|
||||
// the operator got a run that looked like a working T0. Since P11 A1 the tier is
|
||||
// settled at the handshake (Transport/AdoptTier.h): a stream refused T0/T1 there by
|
||||
// name and runs T2, shared segments died there, so a settled session answers true
|
||||
// and only a map_persistent no handshake settled still aborts by name. The return
|
||||
// value is deliberately not a branch: every surviving tier declines (R-6).
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) {
|
||||
(void)MG_Remote::Client::AdoptTierIsEmulate();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user