valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone
923a60
From caca204d23babbdb0c688f543f3ee8d66a1a2001 Mon Sep 17 00:00:00 2001
923a60
From: Lennart Poettering <lennart@poettering.net>
923a60
Date: Wed, 4 May 2016 19:01:56 +0200
923a60
Subject: [PATCH] logind: process session/inhibitor fds at higher priority
923a60
923a60
Let's make sure we process session and inhibitor pipe fds (that signal
923a60
sessions/inhibtors going away) at a higher priority
923a60
than new bus calls that might create new sessions or inhibitors. This helps
923a60
ensuring that the number of open sessions stays minimal.
923a60
923a60
Cherry-picked from: e11544a8305ab9dea097c74bb16e296150c9cc10
923a60
Resolves: #1305608
923a60
---
923a60
 src/login/logind-inhibit.c | 2 +-
923a60
 src/login/logind-session.c | 4 +++-
923a60
 src/login/logind.c         | 2 +-
923a60
 3 files changed, 5 insertions(+), 3 deletions(-)
923a60
923a60
diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c
923a60
index 84fee0e773..bf96898f2d 100644
923a60
--- a/src/login/logind-inhibit.c
923a60
+++ b/src/login/logind-inhibit.c
923a60
@@ -303,7 +303,7 @@ int inhibitor_create_fifo(Inhibitor *i) {
923a60
                 if (r < 0)
923a60
                         return r;
923a60
 
923a60
-                r = sd_event_source_set_priority(i->event_source, SD_EVENT_PRIORITY_IDLE);
923a60
+                r = sd_event_source_set_priority(i->event_source, SD_EVENT_PRIORITY_IDLE-10);
923a60
                 if (r < 0)
923a60
                         return r;
923a60
         }
923a60
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
923a60
index dc24539f12..59f5a7ad5d 100644
923a60
--- a/src/login/logind-session.c
923a60
+++ b/src/login/logind-session.c
923a60
@@ -905,7 +905,9 @@ int session_create_fifo(Session *s) {
923a60
                 if (r < 0)
923a60
                         return r;
923a60
 
923a60
-                r = sd_event_source_set_priority(s->fifo_event_source, SD_EVENT_PRIORITY_IDLE);
923a60
+                /* Let's make sure we noticed dead sessions before we process new bus requests (which might create new
923a60
+                 * sessions). */
923a60
+                r = sd_event_source_set_priority(s->fifo_event_source, SD_EVENT_PRIORITY_NORMAL-10);
923a60
                 if (r < 0)
923a60
                         return r;
923a60
         }
923a60
diff --git a/src/login/logind.c b/src/login/logind.c
923a60
index 3afbf34a13..e8d0669bbf 100644
923a60
--- a/src/login/logind.c
923a60
+++ b/src/login/logind.c
923a60
@@ -685,7 +685,7 @@ static int manager_connect_bus(Manager *m) {
923a60
         if (r < 0)
923a60
                 return log_error_errno(r, "Failed to register name: %m");
923a60
 
923a60
-        r = sd_bus_attach_event(m->bus, m->event, 0);
923a60
+        r = sd_bus_attach_event(m->bus, m->event, SD_EVENT_PRIORITY_NORMAL);
923a60
         if (r < 0)
923a60
                 return log_error_errno(r, "Failed to attach bus to event loop: %m");
923a60