fix: enable endpoint_unx on all posix targets

This commit is contained in:
CJ van den Berg 2026-04-15 13:05:08 +02:00
parent 469e26c0d8
commit a0fa97cdde
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 12 additions and 4 deletions

View file

@ -40,6 +40,14 @@ using namespace std::chrono_literals;
#if !defined(_WIN32) #if !defined(_WIN32)
namespace { namespace {
// Linux supports abstract Unix sockets (null-byte prefix, no filesystem entry).
// FreeBSD and macOS only support file-based Unix sockets.
#if defined(__linux__)
constexpr auto unx_socket_mode = mode::abstract;
#else
constexpr auto unx_socket_mode = mode::file;
#endif
struct controller { struct controller {
handle ep_listen; handle ep_listen;
handle ep_connect; handle ep_connect;
@ -59,7 +67,7 @@ struct controller {
return ok(); return ok();
} }
if (m("path", extract(path))) { if (m("path", extract(path))) {
ep_connect = connect(path).value(); ep_connect = connect(path, unx_socket_mode).value();
return ok(); return ok();
} }
if (m("connected")) { if (m("connected")) {
@ -85,12 +93,12 @@ struct controller {
auto endpoint_unx(context &ctx, bool &result, env_t env_) -> ::result { auto endpoint_unx(context &ctx, bool &result, env_t env_) -> ::result {
stringstream ss; stringstream ss;
ss << "/net/vdbonline/thespian/endpoint_t_" << getpid(); ss << "/tmp/thespian_endpoint_t_" << getpid();
const string path = ss.str(); const string path = ss.str();
return to_result(ctx.spawn_link( return to_result(ctx.spawn_link(
[path]() { [path]() {
link(env().proc("log")); link(env().proc("log"));
handle ep_listen = listen(path).value(); handle ep_listen = listen(path, unx_socket_mode).value();
receive([p{make_shared<controller>(ep_listen)}](const auto &from, receive([p{make_shared<controller>(ep_listen)}](const auto &from,
const auto &m) { const auto &m) {
return p->receive(from, m); return p->receive(from, m);

View file

@ -18,7 +18,7 @@ test "debug" {
} }
test "endpoint_unx" { test "endpoint_unx" {
if (builtin.os.tag == .linux) { if (builtin.os.tag != .windows) {
try testcase("endpoint_unx"); try testcase("endpoint_unx");
} }
} }