ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
Zbigniew Jędrzejewski-Szmek 399a2a
From c98114c5e5c5b9d1e8fea75a0bfb37f0d329fd36 Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek 399a2a
From: David Herrmann <dh.herrmann@gmail.com>
Zbigniew Jędrzejewski-Szmek 399a2a
Date: Wed, 11 Mar 2015 13:53:21 +0100
Zbigniew Jędrzejewski-Szmek 399a2a
Subject: [PATCH] bus-proxy: complain only once about queue overflows
Zbigniew Jędrzejewski-Szmek 399a2a
Zbigniew Jędrzejewski-Szmek 399a2a
If the local peer does not dispatch its incoming queue, the bus-proxy will
Zbigniew Jędrzejewski-Szmek 399a2a
slowly fill its outgoing queue. Once its full, it will continously
Zbigniew Jędrzejewski-Szmek 399a2a
complain that it cannot forward its messages.
Zbigniew Jędrzejewski-Szmek 399a2a
Zbigniew Jędrzejewski-Szmek 399a2a
As it turns out, pulseaudio does have an idle background dbus connection
Zbigniew Jędrzejewski-Szmek 399a2a
that is not integrated into any mainloop (and given that gdbus and
Zbigniew Jędrzejewski-Szmek 399a2a
libdbus1 both support background shared connections, PA is probably not
Zbigniew Jędrzejewski-Szmek 399a2a
the only example), therefore, the bus-proxy will loudly complain if it
Zbigniew Jędrzejewski-Szmek 399a2a
cannot forward NameOwnerChanged events once the queue is full.
Zbigniew Jędrzejewski-Szmek 399a2a
Zbigniew Jędrzejewski-Szmek 399a2a
This commit makes the proxy track queue-state and complain only once the
Zbigniew Jędrzejewski-Szmek 399a2a
queue runs full, not if it is already full.
Zbigniew Jędrzejewski-Szmek 399a2a
Zbigniew Jędrzejewski-Szmek 399a2a
A PA bug-report (and patch) has been filed, and other applications should
Zbigniew Jędrzejewski-Szmek 399a2a
be fixed similarly. Hence, lets keep the error message, instead of
Zbigniew Jędrzejewski-Szmek 399a2a
dropping it. It's unused resources we really want to get rid of, so
Zbigniew Jędrzejewski-Szmek 399a2a
silencing the message does not really help (which is actually what
Zbigniew Jędrzejewski-Szmek 399a2a
dbus-daemon does).
Zbigniew Jędrzejewski-Szmek 399a2a
Zbigniew Jędrzejewski-Szmek 399a2a
(cherry picked from commit ec2c7b56599981a7d9e76b15c75af3e1af3e6f81)
Zbigniew Jędrzejewski-Szmek 399a2a
---
Zbigniew Jędrzejewski-Szmek 399a2a
 src/bus-proxyd/proxy.c | 16 ++++++++++++----
Zbigniew Jędrzejewski-Szmek 399a2a
 src/bus-proxyd/proxy.h |  1 +
Zbigniew Jędrzejewski-Szmek 399a2a
 2 files changed, 13 insertions(+), 4 deletions(-)
Zbigniew Jędrzejewski-Szmek 399a2a
Zbigniew Jędrzejewski-Szmek 399a2a
diff --git a/src/bus-proxyd/proxy.c b/src/bus-proxyd/proxy.c
Zbigniew Jędrzejewski-Szmek 399a2a
index 3dea908f5b..e13cf5e2ea 100644
Zbigniew Jędrzejewski-Szmek 399a2a
--- a/src/bus-proxyd/proxy.c
Zbigniew Jędrzejewski-Szmek 399a2a
+++ b/src/bus-proxyd/proxy.c
Zbigniew Jędrzejewski-Szmek 399a2a
@@ -729,13 +729,21 @@ static int proxy_process_destination_to_local(Proxy *p) {
Zbigniew Jędrzejewski-Szmek 399a2a
 
Zbigniew Jędrzejewski-Szmek 399a2a
                 /* Return the error to the client, if we can */
Zbigniew Jędrzejewski-Szmek 399a2a
                 synthetic_reply_method_errnof(m, r, "Failed to forward message we got from destination: %m");
Zbigniew Jędrzejewski-Szmek 399a2a
-                log_error_errno(r,
Zbigniew Jędrzejewski-Szmek 399a2a
-                         "Failed to forward message we got from destination: uid=" UID_FMT " gid=" GID_FMT" message=%s destination=%s path=%s interface=%s member=%s: %m",
Zbigniew Jędrzejewski-Szmek 399a2a
-                         p->local_creds.uid, p->local_creds.gid, bus_message_type_to_string(m->header->type),
Zbigniew Jędrzejewski-Szmek 399a2a
-                         strna(m->destination), strna(m->path), strna(m->interface), strna(m->member));
Zbigniew Jędrzejewski-Szmek 399a2a
+                if (r == -ENOBUFS) {
Zbigniew Jędrzejewski-Szmek 399a2a
+                        /* if local dbus1 peer does not dispatch its queue, warn only once */
Zbigniew Jędrzejewski-Szmek 399a2a
+                        if (!p->queue_overflow)
Zbigniew Jędrzejewski-Szmek 399a2a
+                                log_error("Dropped messages due to queue overflow of local peer (pid: "PID_FMT" uid: "UID_FMT")", p->local_creds.pid, p->local_creds.uid);
Zbigniew Jędrzejewski-Szmek 399a2a
+                        p->queue_overflow = true;
Zbigniew Jędrzejewski-Szmek 399a2a
+                } else
Zbigniew Jędrzejewski-Szmek 399a2a
+                        log_error_errno(r,
Zbigniew Jędrzejewski-Szmek 399a2a
+                                 "Failed to forward message we got from destination: uid=" UID_FMT " gid=" GID_FMT" message=%s destination=%s path=%s interface=%s member=%s: %m",
Zbigniew Jędrzejewski-Szmek 399a2a
+                                 p->local_creds.uid, p->local_creds.gid, bus_message_type_to_string(m->header->type),
Zbigniew Jędrzejewski-Szmek 399a2a
+                                 strna(m->destination), strna(m->path), strna(m->interface), strna(m->member));
Zbigniew Jędrzejewski-Szmek 399a2a
+
Zbigniew Jędrzejewski-Szmek 399a2a
                 return 1;
Zbigniew Jędrzejewski-Szmek 399a2a
         }
Zbigniew Jędrzejewski-Szmek 399a2a
 
Zbigniew Jędrzejewski-Szmek 399a2a
+        p->queue_overflow = false;
Zbigniew Jędrzejewski-Szmek 399a2a
         return 1;
Zbigniew Jędrzejewski-Szmek 399a2a
 }
Zbigniew Jędrzejewski-Szmek 399a2a
 
Zbigniew Jędrzejewski-Szmek 399a2a
diff --git a/src/bus-proxyd/proxy.h b/src/bus-proxyd/proxy.h
Zbigniew Jędrzejewski-Szmek 399a2a
index 913d47071b..782c4e60b3 100644
Zbigniew Jędrzejewski-Szmek 399a2a
--- a/src/bus-proxyd/proxy.h
Zbigniew Jędrzejewski-Szmek 399a2a
+++ b/src/bus-proxyd/proxy.h
Zbigniew Jędrzejewski-Szmek 399a2a
@@ -40,6 +40,7 @@ struct Proxy {
Zbigniew Jędrzejewski-Szmek 399a2a
         SharedPolicy *policy;
Zbigniew Jędrzejewski-Szmek 399a2a
 
Zbigniew Jędrzejewski-Szmek 399a2a
         bool got_hello : 1;
Zbigniew Jędrzejewski-Szmek 399a2a
+        bool queue_overflow : 1;
Zbigniew Jędrzejewski-Szmek 399a2a
 };
Zbigniew Jędrzejewski-Szmek 399a2a
 
Zbigniew Jędrzejewski-Szmek 399a2a
 int proxy_new(Proxy **out, int in_fd, int out_fd, const char *dest);