mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-16 14:33:24 +09:00
[Fix] (Remote): offer inproc no shared images and refuse them on its server
This commit is contained in:
@@ -184,18 +184,6 @@ namespace MobileGL::MG_Remote::Transport::AdoptT0 {
|
||||
return test != nullptr ? test->HasAhb() : RealHasAhb();
|
||||
}
|
||||
|
||||
namespace {
|
||||
std::atomic<bool> g_peerInAnotherProcessForTest{false};
|
||||
} // namespace
|
||||
|
||||
bool PeerIsThisProcess(bool inProcessTransport) {
|
||||
return inProcessTransport && !g_peerInAnotherProcessForTest.load(std::memory_order_acquire);
|
||||
}
|
||||
|
||||
void SetPeerInAnotherProcessForTest(bool asIfCrossProcess) {
|
||||
g_peerInAnotherProcessForTest.store(asIfCrossProcess, std::memory_order_release);
|
||||
}
|
||||
|
||||
bool AllocateHeld(std::uint64_t size, const void* seed, HeldStore& out, std::string& why) {
|
||||
const PlatformForTest* test = g_testPlatform.load(std::memory_order_acquire);
|
||||
return test != nullptr ? test->AllocateHeld(size, seed, out, why) : RealAllocateHeld(size, seed, out, why);
|
||||
|
||||
@@ -56,13 +56,9 @@ namespace MobileGL::MG_Remote::Transport::AdoptT0 {
|
||||
// True where AHardwareBuffer exists (Android). Everywhere else T0 is never granted.
|
||||
bool PlatformHasAhb();
|
||||
|
||||
// True when a session's peer is this very process (an in-process transport). Such a session
|
||||
// never takes this header's arm: its stores are this process's memory already, so T0 there is
|
||||
// the backend handing over its own store (kCapAdoptInProcess) or nothing (T2).
|
||||
bool PeerIsThisProcess(bool inProcessTransport);
|
||||
// Test seam: the protocol tests run over an in-process transport and stand for a peer in
|
||||
// another process while this is set.
|
||||
void SetPeerInAnotherProcessForTest(bool asIfCrossProcess);
|
||||
// A session whose peer is this very process (Transport::PeerIsThisProcess) never takes this
|
||||
// header's arm: its stores are this process's memory already, so T0 there is the backend
|
||||
// handing over its own store (kCapAdoptInProcess) or nothing (T2).
|
||||
|
||||
// ---- client half ----------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -127,4 +127,12 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
ITransport() = default;
|
||||
};
|
||||
|
||||
// True when the session on `transport` has this very process as its peer (an in-process
|
||||
// transport). Its memory is the peer's already, so what exists only to carry memory between
|
||||
// processes - T0's handle arm, shared images - is never offered on it.
|
||||
bool PeerIsThisProcess(const ITransport* transport);
|
||||
// Test seam: the protocol tests run over an in-process transport and stand for a peer in
|
||||
// another process while this is set.
|
||||
void SetPeerInAnotherProcessForTest(bool asIfCrossProcess);
|
||||
|
||||
} // namespace MobileGL::MG_Remote::Transport
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <MG_Util/Debug/Log.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cerrno>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
@@ -290,4 +291,17 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
|
||||
Doorbell& InProcessTransport::SelfDoorbell() { return m_channel->Bell(m_endpoint); }
|
||||
|
||||
namespace {
|
||||
std::atomic<bool> g_peerInAnotherProcessForTest{false};
|
||||
} // namespace
|
||||
|
||||
bool PeerIsThisProcess(const ITransport* transport) {
|
||||
return transport != nullptr && transport->Role() == TransportRole::InProcess &&
|
||||
!g_peerInAnotherProcessForTest.load(std::memory_order_acquire);
|
||||
}
|
||||
|
||||
void SetPeerInAnotherProcessForTest(bool asIfCrossProcess) {
|
||||
g_peerInAnotherProcessForTest.store(asIfCrossProcess, std::memory_order_release);
|
||||
}
|
||||
|
||||
} // namespace MobileGL::MG_Remote::Transport
|
||||
|
||||
Reference in New Issue
Block a user