Blame SOURCES/0091-bus-proxy-complain-only-once-about-queue-overflows.patch

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