daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
923a60
From a5626cd14a7f27538033e1e110f9a827c0189526 Mon Sep 17 00:00:00 2001
923a60
From: Krzysztof Kotlenga <k.kotlenga@sims.pl>
923a60
Date: Thu, 24 Sep 2015 00:34:51 +0200
923a60
Subject: [PATCH] sd-event: fix prepare priority queue comparison function
923a60
923a60
Otherwise a disabled event source can get swapped with an enabled one
923a60
and cause a severe sd-event malfunction.
923a60
923a60
http://lists.freedesktop.org/archives/systemd-devel/2015-September/034356.html
923a60
923a60
Cherry-picked from: 8046c4576a68977a1089d2585866bfab8152661b
923a60
Resolves: #1266479
923a60
---
923a60
 src/libsystemd/sd-event/sd-event.c | 12 ++++++------
923a60
 1 file changed, 6 insertions(+), 6 deletions(-)
923a60
923a60
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
923a60
index c6350be9f4..1f1e6fe917 100644
923a60
--- a/src/libsystemd/sd-event/sd-event.c
923a60
+++ b/src/libsystemd/sd-event/sd-event.c
923a60
@@ -231,6 +231,12 @@ static int prepare_prioq_compare(const void *a, const void *b) {
923a60
         assert(x->prepare);
923a60
         assert(y->prepare);
923a60
 
923a60
+        /* Enabled ones first */
923a60
+        if (x->enabled != SD_EVENT_OFF && y->enabled == SD_EVENT_OFF)
923a60
+                return -1;
923a60
+        if (x->enabled == SD_EVENT_OFF && y->enabled != SD_EVENT_OFF)
923a60
+                return 1;
923a60
+
923a60
         /* Move most recently prepared ones last, so that we can stop
923a60
          * preparing as soon as we hit one that has already been
923a60
          * prepared in the current iteration */
923a60
@@ -239,12 +245,6 @@ static int prepare_prioq_compare(const void *a, const void *b) {
923a60
         if (x->prepare_iteration > y->prepare_iteration)
923a60
                 return 1;
923a60
 
923a60
-        /* Enabled ones first */
923a60
-        if (x->enabled != SD_EVENT_OFF && y->enabled == SD_EVENT_OFF)
923a60
-                return -1;
923a60
-        if (x->enabled == SD_EVENT_OFF && y->enabled != SD_EVENT_OFF)
923a60
-                return 1;
923a60
-
923a60
         /* Lower priority values first */
923a60
         if (x->priority < y->priority)
923a60
                 return -1;