summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-08-28 15:47:39 +0200
committerTom Gundersen <teg@jklm.no>2014-08-28 21:19:17 +0200
commitf7f53e9e6ebb9f656d880f5e779fc174a1d983bf (patch)
tree536c9c216d265f0773dfd4c683b5d1a19cf790de
parent5968b1c304188e466759b8ba419fc10f150e5541 (diff)
sd-event: allow naming event sources
-rw-r--r--src/libsystemd/libsystemd.sym.m42
-rw-r--r--src/libsystemd/sd-event/sd-event.c29
-rw-r--r--src/systemd/sd-event.h2
3 files changed, 33 insertions, 0 deletions
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);