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.
This commit is contained in:
Yu Watanabe
2018-11-10 22:53:00 +09:00
parent bf7712b63e
commit deb2b7348e
9 changed files with 44 additions and 43 deletions
+5 -19
View File
@@ -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;
}
@@ -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);