92 lines
2.9 KiB
Diff
92 lines
2.9 KiB
Diff
|
From f7f53e9e6ebb9f656d880f5e779fc174a1d983bf Mon Sep 17 00:00:00 2001
|
||
|
From: Tom Gundersen <teg@jklm.no>
|
||
|
Date: Thu, 28 Aug 2014 15:47:39 +0200
|
||
|
Subject: [PATCH] sd-event: allow naming event sources
|
||
|
|
||
|
---
|
||
|
src/libsystemd/libsystemd.sym.m4 | 2 ++
|
||
|
src/libsystemd/sd-event/sd-event.c | 29 +++++++++++++++++++++++++++++
|
||
|
src/systemd/sd-event.h | 2 ++
|
||
|
3 files changed, 33 insertions(+)
|
||
|
|
||
|
diff --git a/src/libsystemd/libsystemd.sym.m4 b/src/libsystemd/libsystemd.sym.m4
|
||
|
index 3fc9983f98..d1450fbb26 100644
|
||
|
--- a/src/libsystemd/libsystemd.sym.m4
|
||
|
+++ b/src/libsystemd/libsystemd.sym.m4
|
||
|
@@ -382,6 +382,8 @@ global:
|
||
|
sd_event_get_watchdog;
|
||
|
sd_event_source_ref;
|
||
|
sd_event_source_unref;
|
||
|
+ sd_event_source_set_name;
|
||
|
+ sd_event_source_get_name;
|
||
|
sd_event_source_set_prepare;
|
||
|
sd_event_source_get_pending;
|
||
|
sd_event_source_get_priority;
|
||
|
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
|
||
|
index 32777e386b..a2935abd64 100644
|
||
|
--- a/src/libsystemd/sd-event/sd-event.c
|
||
|
+++ b/src/libsystemd/sd-event/sd-event.c
|
||
|
@@ -66,6 +66,8 @@ struct sd_event_source {
|
||
|
void *userdata;
|
||
|
sd_event_handler_t prepare;
|
||
|
|
||
|
+ char *name;
|
||
|
+
|
||
|
EventSourceType type:5;
|
||
|
int enabled:3;
|
||
|
bool pending:1;
|
||
|
@@ -685,6 +687,7 @@ static void source_free(sd_event_source *s) {
|
||
|
assert(s);
|
||
|
|
||
|
source_disconnect(s);
|
||
|
+ free(s->name);
|
||
|
free(s);
|
||
|
}
|
||
|
|
||
|
@@ -1223,6 +1226,32 @@ _public_ sd_event_source* sd_event_source_unref(sd_event_source *s) {
|
||
|
return NULL;
|
||
|
}
|
||
|
|
||
|
+_public_ int sd_event_source_set_name(sd_event_source *s, const char *name) {
|
||
|
+ char *new_name = NULL;
|
||
|
+
|
||
|
+ assert_return(s, -EINVAL);
|
||
|
+
|
||
|
+ if (name) {
|
||
|
+ new_name = strdup(name);
|
||
|
+ if (!new_name)
|
||
|
+ return -ENOMEM;
|
||
|
+ }
|
||
|
+
|
||
|
+ free(s->name);
|
||
|
+ s->name = new_name;
|
||
|
+
|
||
|
+ return 0;
|
||
|
+}
|
||
|
+
|
||
|
+_public_ int sd_event_source_get_name(sd_event_source *s, const char **name) {
|
||
|
+ assert_return(s, -EINVAL);
|
||
|
+ assert_return(name, -EINVAL);
|
||
|
+
|
||
|
+ *name = s->name;
|
||
|
+
|
||
|
+ return 0;
|
||
|
+}
|
||
|
+
|
||
|
_public_ sd_event *sd_event_source_get_event(sd_event_source *s) {
|
||
|
assert_return(s, NULL);
|
||
|
|
||
|
diff --git a/src/systemd/sd-event.h b/src/systemd/sd-event.h
|
||
|
index 8e013b33f6..0dbdcdf2a5 100644
|
||
|
--- a/src/systemd/sd-event.h
|
||
|
+++ b/src/systemd/sd-event.h
|
||
|
@@ -109,6 +109,8 @@ sd_event *sd_event_source_get_event(sd_event_source *s);
|
||
|
void* sd_event_source_get_userdata(sd_event_source *s);
|
||
|
void* sd_event_source_set_userdata(sd_event_source *s, void *userdata);
|
||
|
|
||
|
+int sd_event_source_set_name(sd_event_source *s, const char *name);
|
||
|
+int sd_event_source_get_name(sd_event_source *s, const char **name);
|
||
|
int sd_event_source_set_prepare(sd_event_source *s, sd_event_handler_t callback);
|
||
|
int sd_event_source_get_pending(sd_event_source *s);
|
||
|
int sd_event_source_get_priority(sd_event_source *s, int64_t *priority);
|