summaryrefslogtreecommitdiff
path: root/src/nm-auth-subject.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-04-08 11:57:55 +0200
committerThomas Haller <thaller@redhat.com>2019-04-09 20:40:18 +0200
commite04dc445ec00f8e82bbc1b9ef614b50c906d6606 (patch)
treef5facac1ff4676fcb7062e177f664ca93c198e08 /src/nm-auth-subject.c
parent5d86f605263200667f2c848f89f3b8831f20bb65 (diff)
downloadNetworkManager-e04dc445ec00f8e82bbc1b9ef614b50c906d6606.tar.gz
dbus: cache GetConnectionUnixProcessID and GetConnectionUnixUser
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.
Diffstat (limited to 'src/nm-auth-subject.c')
-rw-r--r--src/nm-auth-subject.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nm-auth-subject.c b/src/nm-auth-subject.c
index dff331a8d8..5599201ef7 100644
--- a/src/nm-auth-subject.c
+++ b/src/nm-auth-subject.c
@@ -173,9 +173,10 @@ _new_unix_process (GDBusMethodInvocation *context,
GDBusMessage *message)
{
NMAuthSubject *self;
- gboolean success = FALSE;
- gulong pid = 0, uid = 0;
- gs_free char *dbus_sender = NULL;
+ const char *dbus_sender = NULL;
+ gulong uid = 0;
+ gulong pid = 0;
+ gboolean success;
g_return_val_if_fail (context || (connection && message), NULL);