naccyde / rpms / systemd

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