mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 17:51:22 +03:00
sd-event: add sd_event_source_{get,set}_floating()
This commit is contained in:
parent
b3ae7237c6
commit
2382c9367b
@ -663,4 +663,7 @@ global:
|
||||
sd_device_monitor_filter_add_match_tag;
|
||||
sd_device_monitor_filter_update;
|
||||
sd_device_monitor_filter_remove;
|
||||
|
||||
sd_event_source_get_floating;
|
||||
sd_event_source_set_floating;
|
||||
} LIBSYSTEMD_239;
|
||||
|
@ -3702,3 +3702,31 @@ _public_ int sd_event_source_get_destroy_callback(sd_event_source *s, sd_event_d
|
||||
|
||||
return !!s->destroy_callback;
|
||||
}
|
||||
|
||||
_public_ int sd_event_source_get_floating(sd_event_source *s) {
|
||||
assert_return(s, -EINVAL);
|
||||
|
||||
return s->floating;
|
||||
}
|
||||
|
||||
_public_ int sd_event_source_set_floating(sd_event_source *s, int b) {
|
||||
assert_return(s, -EINVAL);
|
||||
|
||||
if (s->floating == !!b)
|
||||
return 0;
|
||||
|
||||
if (!s->event) /* Already disconnected */
|
||||
return -ESTALE;
|
||||
|
||||
s->floating = b;
|
||||
|
||||
if (b) {
|
||||
sd_event_source_ref(s);
|
||||
sd_event_unref(s->event);
|
||||
} else {
|
||||
sd_event_ref(s->event);
|
||||
sd_event_source_unref(s);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -143,6 +143,8 @@ int sd_event_source_get_child_pid(sd_event_source *s, pid_t *pid);
|
||||
int sd_event_source_get_inotify_mask(sd_event_source *s, uint32_t *ret);
|
||||
int sd_event_source_set_destroy_callback(sd_event_source *s, sd_event_destroy_t callback);
|
||||
int sd_event_source_get_destroy_callback(sd_event_source *s, sd_event_destroy_t *ret);
|
||||
int sd_event_source_get_floating(sd_event_source *s);
|
||||
int sd_event_source_set_floating(sd_event_source *s, int b);
|
||||
|
||||
/* Define helpers so that __attribute__((cleanup(sd_event_unrefp))) and similar may be used. */
|
||||
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_event, sd_event_unref);
|
||||
|
Loading…
Reference in New Issue
Block a user