diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-10 14:50:11 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-10 14:53:00 +0100 |
commit | deb2b7348e746df9a471b61d71b41b0e871cacde (patch) | |
tree | 815fecf2b58edae1cc1394911fa10981d34a25f9 /src/libsystemd | |
parent | sd-device: add sd_device_monitor_get_event_source() (diff) | |
download | systemd-deb2b7348e746df9a471b61d71b41b0e871cacde.tar.xz systemd-deb2b7348e746df9a471b61d71b41b0e871cacde.zip |
sd-device: drop priority and description from sd_device_monitor_attach_event() and sd_device_monitor_start()
Now we have sd_device_monitor_get_event_soruce(). So, it is not
necessary to include these parameters in the functions for sd_device_monitor.
Diffstat (limited to 'src/libsystemd')
-rw-r--r-- | src/libsystemd/sd-device/device-monitor.c | 24 | ||||
-rw-r--r-- | src/libsystemd/sd-device/test-sd-device-monitor.c | 12 |
2 files changed, 13 insertions, 23 deletions
diff --git a/src/libsystemd/sd-device/device-monitor.c b/src/libsystemd/sd-device/device-monitor.c index 1ef2974003..da99971b02 100644 --- a/src/libsystemd/sd-device/device-monitor.c +++ b/src/libsystemd/sd-device/device-monitor.c @@ -37,7 +37,6 @@ struct sd_device_monitor { sd_event *event; sd_event_source *event_source; - int64_t event_priority; sd_device_monitor_handler_t callback; void *userdata; }; @@ -200,14 +199,13 @@ static int device_monitor_event_handler(sd_event_source *s, int fd, uint32_t rev return 0; } -_public_ int sd_device_monitor_start(sd_device_monitor *m, sd_device_monitor_handler_t callback, void *userdata, const char *description) { - _cleanup_(sd_event_source_unrefp) sd_event_source *s = NULL; +_public_ int sd_device_monitor_start(sd_device_monitor *m, sd_device_monitor_handler_t callback, void *userdata) { int r; assert_return(m, -EINVAL); if (!m->event) { - r = sd_device_monitor_attach_event(m, NULL, 0); + r = sd_device_monitor_attach_event(m, NULL); if (r < 0) return r; } @@ -219,21 +217,11 @@ _public_ int sd_device_monitor_start(sd_device_monitor *m, sd_device_monitor_han m->callback = callback; m->userdata = userdata; - r = sd_event_add_io(m->event, &s, m->sock, EPOLLIN, device_monitor_event_handler, m); + r = sd_event_add_io(m->event, &m->event_source, m->sock, EPOLLIN, device_monitor_event_handler, m); if (r < 0) return r; - r = sd_event_source_set_priority(s, m->event_priority); - if (r < 0) - return r; - - if (description) { - r = sd_event_source_set_description(s, description); - if (r < 0) - return r; - } - - m->event_source = TAKE_PTR(s); + (void) sd_event_source_set_description(m->event_source, "sd-device-monitor"); return 0; } @@ -247,7 +235,7 @@ _public_ int sd_device_monitor_detach_event(sd_device_monitor *m) { return 0; } -_public_ int sd_device_monitor_attach_event(sd_device_monitor *m, sd_event *event, int64_t priority) { +_public_ int sd_device_monitor_attach_event(sd_device_monitor *m, sd_event *event) { int r; assert_return(m, -EINVAL); @@ -261,8 +249,6 @@ _public_ int sd_device_monitor_attach_event(sd_device_monitor *m, sd_event *even return 0; } - m->event_priority = priority; - return 0; } diff --git a/src/libsystemd/sd-device/test-sd-device-monitor.c b/src/libsystemd/sd-device/test-sd-device-monitor.c index 56cf1af434..b703bdee2d 100644 --- a/src/libsystemd/sd-device/test-sd-device-monitor.c +++ b/src/libsystemd/sd-device/test-sd-device-monitor.c @@ -39,11 +39,13 @@ static int test_loopback(bool subsystem_filter, bool tag_filter, bool use_bpf) { assert_se(device_add_property(loopback, "SEQNUM", "10") >= 0); assert_se(device_monitor_new_full(&monitor_server, MONITOR_GROUP_NONE, -1) >= 0); - assert_se(sd_device_monitor_start(monitor_server, NULL, NULL, NULL) >= 0); + assert_se(sd_device_monitor_start(monitor_server, NULL, NULL) >= 0); + assert_se(sd_event_source_set_description(sd_device_monitor_get_event_source(monitor_server), "sender") >= 0); assert_se(device_monitor_new_full(&monitor_client, MONITOR_GROUP_NONE, -1) >= 0); assert_se(device_monitor_allow_unicast_sender(monitor_client, monitor_server) >= 0); - assert_se(sd_device_monitor_start(monitor_client, monitor_handler, (void *) syspath, "loopback-monitor") >= 0); + assert_se(sd_device_monitor_start(monitor_client, monitor_handler, (void *) syspath) >= 0); + assert_se(sd_event_source_set_description(sd_device_monitor_get_event_source(monitor_client), "receiver") >= 0); if (subsystem_filter) { assert_se(sd_device_get_subsystem(loopback, &subsystem) >= 0); @@ -82,12 +84,14 @@ static void test_subsystem_filter(void) { assert_se(device_add_property(loopback, "SEQNUM", "10") >= 0); assert_se(device_monitor_new_full(&monitor_server, MONITOR_GROUP_NONE, -1) >= 0); - assert_se(sd_device_monitor_start(monitor_server, NULL, NULL, NULL) >= 0); + assert_se(sd_device_monitor_start(monitor_server, NULL, NULL) >= 0); + assert_se(sd_event_source_set_description(sd_device_monitor_get_event_source(monitor_server), "sender") >= 0); assert_se(device_monitor_new_full(&monitor_client, MONITOR_GROUP_NONE, -1) >= 0); assert_se(device_monitor_allow_unicast_sender(monitor_client, monitor_server) >= 0); assert_se(sd_device_monitor_filter_add_match_subsystem_devtype(monitor_client, subsystem, NULL) >= 0); - assert_se(sd_device_monitor_start(monitor_client, monitor_handler, (void *) syspath, "subsystem-filter") >= 0); + assert_se(sd_device_monitor_start(monitor_client, monitor_handler, (void *) syspath) >= 0); + assert_se(sd_event_source_set_description(sd_device_monitor_get_event_source(monitor_client), "receiver") >= 0); assert_se(sd_device_enumerator_new(&e) >= 0); assert_se(sd_device_enumerator_add_match_subsystem(e, subsystem, false) >= 0); |