-
Thomas Haller authored
We call GetConnectionUnixProcessID and GetConnectionUnixUser *a lot*. And we do so synchronously. Both is a problem. To avoid the first problem, cache the last few requests with each cached value being valid for one second. On a quick test, this saves 98% of the requests: 59 GetConnectionUnixProcessID(*) 3201 GetConnectionUnixProcessID(*) (served from cache) 59 GetConnectionUnixUser(*) 3201 GetConnectionUnixUser(*) (served from cache) Note that now as we serve requests from the cache, it might be the case that the D-Bus endpoint already disconnected. Previously, the request would have failed but now we return the cached user-id and process-id. This problem is mitigated by only caching the values for up to one second. Also, it's not really a problem because we cache sender names. Those are supposed to be unique and not repeat. So, even if the peer already disconnected, it is still true that the corresponding PID/UID was as we have cached it. We don't use this API for checking whether the peer is still connected, but what UID/PID it has/had. That answer is still correct for the cached value after the peer disconnected.
e04dc445