mirror of
https://github.com/troglobit/finit.git
synced 2026-10-27 12:20:54 +00:00
libink/dbus: give parked and outstanding calls a deadline
A call is parked until the resolver says who sent it, and an outbound call sits in a pending slot until its reply lands. Neither had a way to give up. A broker that answers GetConnectionUnixUser slowly, or not at all, leaves the caller waiting forever and keeps the slot; four of those and every later privileged call is refused with LimitsExceeded until Finit restarts. libink cannot time itself out, it has no event loop, so the deadline is the embedder's to keep. One sweep per connection covers both, and the ordering between them stays in the library rather than in each embedder: calls first, because one timing out usually resolves the park it was made for, and AccessDenied tells that caller more than a bare timeout. The sweep is armed when a resolve is deferred and stops rearming as soon as nothing is outstanding, so a system that never meets a broker never wakes up for it. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
a1969efac1
commit
853e226812
6 files changed
+172
-5
No files matched your search
@@ -87,6 +87,7 @@ int link_connection_call(link_connection_t *conn, const char *destination,
|
||||
|
||||
bus->pending[i].used = 1;
|
||||
bus->pending[i].serial = serial;
|
||||
bus->pending[i].stamp = __now_ms();
|
||||
bus->pending[i].cb = cb;
|
||||
bus->pending[i].userdata = userdata;
|
||||
|
||||
@@ -107,6 +108,45 @@ void __bus_free(link_connection_t *conn)
|
||||
conn->bus = NULL;
|
||||
}
|
||||
|
||||
/* Neither half can time itself out, libink has no event loop, so the
|
||||
* embedder sweeps. Calls go first: one timing out usually resolves
|
||||
* the park it was made for, and being told AccessDenied says more to
|
||||
* that caller than a bare timeout. */
|
||||
int link_connection_expire(link_connection_t *conn, unsigned int age_ms)
|
||||
{
|
||||
struct link_bus *bus;
|
||||
uint64_t now;
|
||||
int i, live = 0;
|
||||
|
||||
if (!conn || !conn->bus)
|
||||
return 0;
|
||||
|
||||
bus = conn->bus;
|
||||
now = __now_ms();
|
||||
for (i = 0; i < LINK_PENDING_CAP; i++) {
|
||||
link_reply_cb_t cb;
|
||||
void *userdata;
|
||||
|
||||
if (!bus->pending[i].used)
|
||||
continue;
|
||||
|
||||
if (now - bus->pending[i].stamp < age_ms) {
|
||||
live++;
|
||||
continue;
|
||||
}
|
||||
|
||||
cb = bus->pending[i].cb;
|
||||
userdata = bus->pending[i].userdata;
|
||||
bus->pending[i].used = 0;
|
||||
|
||||
__dbg("timed out call serial %u, no reply", bus->pending[i].serial);
|
||||
if (cb)
|
||||
cb(conn, NULL, userdata);
|
||||
}
|
||||
|
||||
return live + __dispatch_expire_parked(conn, age_ms);
|
||||
}
|
||||
|
||||
void link_connection_close(link_connection_t *conn)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
Reference in new issue
Block a user