Introduces the four rpc-layer seams docs/08-porting.md calls for this lane: platform::Wakeup (eventfd), platform::peer_of (SO_PEERCRED/struct ucred, same-UID check preserved unchanged), platform::acquire_instance_lock (abstract-namespace socket), platform::runtime_base_dir/data_base_dir (XDG lookups). Today's Linux code moves unchanged into daemon/src/rpc/platform/linux/; the seam headers carry no OS types and no #ifdef. No fifth interface for timerfd: EventLoop gains a portable add_timer() that folds the next deadline into poll()'s own timeout, replacing both timerfd instances in main.cpp — the loop already computes a deadline, so this needs no per-OS backend at all. Full suite 59/59 green; no #ifdef outside platform/linux/, no behaviour change. Co-Authored-By: Claude Sonnet 5 <[email protected]>
21 lines
900 B
C++
21 lines
900 B
C++
#pragma once
|
|
|
|
// Single-instance guard, keyed by the resolved runtime directory (see rpc/runtime_dir.hpp)
|
|
// so isolated instances pointed at different runtime dirs never contend (docs/01 §2). The
|
|
// mechanism is Linux's abstract-namespace Unix socket; macOS has no abstract namespace and
|
|
// uses a real socket file plus flock() instead, which must unlink a stale socket left by a
|
|
// crashed process (docs/08-porting.md "API mapping" — the abstract version got that for
|
|
// free from the kernel).
|
|
|
|
#include <string>
|
|
#include <system_error>
|
|
|
|
namespace velox::daemon::rpc::platform {
|
|
|
|
// Returns the held fd (kept open for the process lifetime; closing it releases the lock)
|
|
// or -1 if another process already holds the lock for this exact `runtime_dir`, or on any
|
|
// other error acquiring it.
|
|
int acquire_instance_lock(const std::string& runtime_dir);
|
|
|
|
} // namespace velox::daemon::rpc::platform
|