49 lines
2.1 KiB
Diff
49 lines
2.1 KiB
Diff
From b291d260e0ebc7a7528f37e97e8b404968f34e18 Mon Sep 17 00:00:00 2001
|
|
From: Martin Ejdestig <marejde@gmail.com>
|
|
Date: Tue, 22 Nov 2016 01:21:00 +0100
|
|
Subject: [PATCH] sd-event: fix sd_event_source_get_priority() (#4712)
|
|
|
|
To properly store priority in passed in pointer and return 0 for success.
|
|
Also add a test for verifying that it works correctly.
|
|
(cherry picked from commit 6680b8d118490bbb3e5522729ec50d9975088fd5)
|
|
---
|
|
src/libsystemd/sd-event/sd-event.c | 3 ++-
|
|
src/libsystemd/sd-event/test-event.c | 3 +++
|
|
2 files changed, 5 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
|
|
index 9857f8b1fc..f94959adac 100644
|
|
--- a/src/libsystemd/sd-event/sd-event.c
|
|
+++ b/src/libsystemd/sd-event/sd-event.c
|
|
@@ -1539,7 +1539,8 @@ _public_ int sd_event_source_get_priority(sd_event_source *s, int64_t *priority)
|
|
assert_return(s, -EINVAL);
|
|
assert_return(!event_pid_changed(s->event), -ECHILD);
|
|
|
|
- return s->priority;
|
|
+ *priority = s->priority;
|
|
+ return 0;
|
|
}
|
|
|
|
_public_ int sd_event_source_set_priority(sd_event_source *s, int64_t priority) {
|
|
diff --git a/src/libsystemd/sd-event/test-event.c b/src/libsystemd/sd-event/test-event.c
|
|
index 289114490c..c0e5e06a18 100644
|
|
--- a/src/libsystemd/sd-event/test-event.c
|
|
+++ b/src/libsystemd/sd-event/test-event.c
|
|
@@ -172,6 +172,7 @@ static void test_basic(void) {
|
|
static const char ch = 'x';
|
|
int a[2] = { -1, -1 }, b[2] = { -1, -1}, d[2] = { -1, -1}, k[2] = { -1, -1 };
|
|
uint64_t event_now;
|
|
+ int64_t priority;
|
|
|
|
assert_se(pipe(a) >= 0);
|
|
assert_se(pipe(b) >= 0);
|
|
@@ -209,6 +210,8 @@ static void test_basic(void) {
|
|
assert_se(sd_event_add_exit(e, &q, exit_handler, INT_TO_PTR('g')) >= 0);
|
|
|
|
assert_se(sd_event_source_set_priority(x, 99) >= 0);
|
|
+ assert_se(sd_event_source_get_priority(x, &priority) >= 0);
|
|
+ assert_se(priority == 99);
|
|
assert_se(sd_event_source_set_enabled(y, SD_EVENT_ONESHOT) >= 0);
|
|
assert_se(sd_event_source_set_prepare(x, prepare_handler) >= 0);
|
|
assert_se(sd_event_source_set_priority(z, 50) >= 0);
|