aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-01-08 18:44:48 +0100
committerbptato <nincsnevem662@gmail.com>2025-01-08 21:05:44 +0100
commitb3e57e3726b3654794057119a3c553312d40426b (patch)
treea45790656287934f99da2c6c7be7c0f923ba640c /doc
parent9a6512c608dc119d74bc3c57029bf3bf60bad891 (diff)
downloadchawan-b3e57e3726b3654794057119a3c553312d40426b.tar.gz
loader: use per-process control sockets
Previously, each message (load, resume, passFd, etc.) would open a new connection to loader's UNIX socket, and assumed the loader was dead when the loader did not respond (ECONNREFUSED). As it turns out, this model was hopelessly broken: POSIX does not specify when a UNIX socket can refuse connections, so while it happened to work on Linux (which just blocks if it can't accept right now), FreeBSD would randomly refuse connections whenever its listen queue was full. Instead, we now take a socketpair() from the loader in addClient, and pass on one half to the client (the other half stays in loader); this is the control stream, and all messages from the specific client are sent through it. If a message includes a new stream (e.g. lcLoad), then it sends a new socketpair through the control stream. Aside from not being completely broken (and being marginally more efficient), this arrangement has several other benefits: it removes the need for authentication, almost removes the need for sockdir (now only buffers use it), and will make it easier to add async message processing in the future.
Diffstat (limited to 'doc')
-rw-r--r--doc/architecture.md10
1 files changed, 5 insertions, 5 deletions
diff --git a/doc/architecture.md b/doc/architecture.md
index 9153a290..e368addb 100644
--- a/doc/architecture.md
+++ b/doc/architecture.md
@@ -112,11 +112,11 @@ following steps:
obviously, it's more efficient this way.)
The loader process distinguishes between clients (i.e processes) through
-client keys (session cookies). In theory this should help against rogue
-clients, though in practice it is still trivial to crash the loader as
-a client. It also helps us block further requests from buffers that have
-been discarded by the pager, but still haven't found out yet that their
-life time has ended.
+their control stream (one end of a socketpair created by loader). In
+theory this should help against rogue clients, though in practice it is
+still trivial to crash the loader as a client. It also helps us block
+further requests from buffers that have been discarded by the pager, but
+still haven't found out yet that their life time has ended.
### Buffer