summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/device.c4
-rw-r--r--src/libsystemd/sd-device/device-monitor.c24
-rw-r--r--src/libsystemd/sd-device/test-sd-device-monitor.c12
-rw-r--r--src/login/logind.c24
-rw-r--r--src/network/networkd-manager.c4
-rw-r--r--src/rfkill/rfkill.c4
-rw-r--r--src/systemd/sd-device.h4
-rw-r--r--src/udev/udevadm-monitor.c7
-rw-r--r--src/udev/udevadm-trigger.c4
9 files changed, 44 insertions, 43 deletions
diff --git a/src/core/device.c b/src/core/device.c
index 6c50fd7832..8b6126c4cf 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -802,13 +802,13 @@ static void device_enumerate(Manager *m) {
goto fail;
}
- r = sd_device_monitor_attach_event(m->device_monitor, m->event, 0);
+ r = sd_device_monitor_attach_event(m->device_monitor, m->event);
if (r < 0) {
log_error_errno(r, "Failed to attach event to device monitor: %m");
goto fail;
}
- r = sd_device_monitor_start(m->device_monitor, device_dispatch_io, m, "systemd-device-monitor");
+ r = sd_device_monitor_start(m->device_monitor, device_dispatch_io, m);
if (r < 0) {
log_error_errno(r, "Failed to start device monitor: %m");
goto fail;
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);
diff --git a/src/login/logind.c b/src/login/logind.c
index e7de3c12e4..a1ab9626b5 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -832,14 +832,16 @@ static int manager_connect_udev(Manager *m) {
if (r < 0)
return r;
- r = sd_device_monitor_attach_event(m->device_seat_monitor, m->event, 0);
+ r = sd_device_monitor_attach_event(m->device_seat_monitor, m->event);
if (r < 0)
return r;
- r = sd_device_monitor_start(m->device_seat_monitor, manager_dispatch_seat_udev, m, "logind-seat-monitor");
+ r = sd_device_monitor_start(m->device_seat_monitor, manager_dispatch_seat_udev, m);
if (r < 0)
return r;
+ (void) sd_event_source_set_description(sd_device_monitor_get_event_source(m->device_seat_monitor), "logind-seat-monitor");
+
r = sd_device_monitor_new(&m->device_monitor);
if (r < 0)
return r;
@@ -856,14 +858,16 @@ static int manager_connect_udev(Manager *m) {
if (r < 0)
return r;
- r = sd_device_monitor_attach_event(m->device_monitor, m->event, 0);
+ r = sd_device_monitor_attach_event(m->device_monitor, m->event);
if (r < 0)
return r;
- r = sd_device_monitor_start(m->device_monitor, manager_dispatch_device_udev, m, "logind-device-monitor");
+ r = sd_device_monitor_start(m->device_monitor, manager_dispatch_device_udev, m);
if (r < 0)
return r;
+ (void) sd_event_source_set_description(sd_device_monitor_get_event_source(m->device_monitor), "logind-device-monitor");
+
/* Don't watch keys if nobody cares */
if (!manager_all_buttons_ignored(m)) {
r = sd_device_monitor_new(&m->device_button_monitor);
@@ -878,13 +882,15 @@ static int manager_connect_udev(Manager *m) {
if (r < 0)
return r;
- r = sd_device_monitor_attach_event(m->device_button_monitor, m->event, 0);
+ r = sd_device_monitor_attach_event(m->device_button_monitor, m->event);
if (r < 0)
return r;
- r = sd_device_monitor_start(m->device_button_monitor, manager_dispatch_button_udev, m, "logind-button-monitor");
+ r = sd_device_monitor_start(m->device_button_monitor, manager_dispatch_button_udev, m);
if (r < 0)
return r;
+
+ (void) sd_event_source_set_description(sd_device_monitor_get_event_source(m->device_button_monitor), "logind-button-monitor");
}
/* Don't bother watching VCSA devices, if nobody cares */
@@ -898,13 +904,15 @@ static int manager_connect_udev(Manager *m) {
if (r < 0)
return r;
- r = sd_device_monitor_attach_event(m->device_vcsa_monitor, m->event, 0);
+ r = sd_device_monitor_attach_event(m->device_vcsa_monitor, m->event);
if (r < 0)
return r;
- r = sd_device_monitor_start(m->device_vcsa_monitor, manager_dispatch_vcsa_udev, m, "logind-vcsa-monitor");
+ r = sd_device_monitor_start(m->device_vcsa_monitor, manager_dispatch_vcsa_udev, m);
if (r < 0)
return r;
+
+ (void) sd_event_source_set_description(sd_device_monitor_get_event_source(m->device_vcsa_monitor), "logind-vcsa-monitor");
}
return 0;
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index 69861a680e..2b5fc3a50b 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -240,11 +240,11 @@ static int manager_connect_udev(Manager *m) {
if (r < 0)
return log_error_errno(r, "Could not add device monitor filter: %m");
- r = sd_device_monitor_attach_event(m->device_monitor, m->event, 0);
+ r = sd_device_monitor_attach_event(m->device_monitor, m->event);
if (r < 0)
return log_error_errno(r, "Failed to attach event to device monitor: %m");
- r = sd_device_monitor_start(m->device_monitor, manager_udev_process_link, m, "networkd-device-monitor");
+ r = sd_device_monitor_start(m->device_monitor, manager_udev_process_link, m);
if (r < 0)
return log_error_errno(r, "Failed to start device monitor: %m");
diff --git a/src/rfkill/rfkill.c b/src/rfkill/rfkill.c
index 9e7d201add..47181bfc16 100644
--- a/src/rfkill/rfkill.c
+++ b/src/rfkill/rfkill.c
@@ -138,11 +138,11 @@ static int wait_for_initialized(
if (r < 0)
return log_error_errno(r, "Failed to add rfkill device match to monitor: %m");
- r = sd_device_monitor_attach_event(monitor, event, 0);
+ r = sd_device_monitor_attach_event(monitor, event);
if (r < 0)
return log_error_errno(r, "Failed to attach event to device monitor: %m");
- r = sd_device_monitor_start(monitor, device_monitor_handler, &data, "rfkill-device-monitor");
+ r = sd_device_monitor_start(monitor, device_monitor_handler, &data);
if (r < 0)
return log_error_errno(r, "Failed to start device monitor: %m");
diff --git a/src/systemd/sd-device.h b/src/systemd/sd-device.h
index 4793e29237..3c5c88c56b 100644
--- a/src/systemd/sd-device.h
+++ b/src/systemd/sd-device.h
@@ -103,11 +103,11 @@ sd_device_monitor *sd_device_monitor_ref(sd_device_monitor *m);
sd_device_monitor *sd_device_monitor_unref(sd_device_monitor *m);
int sd_device_monitor_set_receive_buffer_size(sd_device_monitor *m, size_t size);
-int sd_device_monitor_attach_event(sd_device_monitor *m, sd_event *event, int64_t priority);
+int sd_device_monitor_attach_event(sd_device_monitor *m, sd_event *event);
int sd_device_monitor_detach_event(sd_device_monitor *m);
sd_event *sd_device_monitor_get_event(sd_device_monitor *m);
sd_event_source *sd_device_monitor_get_event_source(sd_device_monitor *m);
-int sd_device_monitor_start(sd_device_monitor *m, sd_device_monitor_handler_t callback, void *userdata, const char *description);
+int sd_device_monitor_start(sd_device_monitor *m, sd_device_monitor_handler_t callback, void *userdata);
int sd_device_monitor_stop(sd_device_monitor *m);
int sd_device_monitor_filter_add_match_subsystem_devtype(sd_device_monitor *m, const char *subsystem, const char *devtype);
diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c
index ae8e06111e..f7737d0790 100644
--- a/src/udev/udevadm-monitor.c
+++ b/src/udev/udevadm-monitor.c
@@ -67,7 +67,7 @@ static int setup_monitor(MonitorNetlinkGroup sender, sd_event *event, sd_device_
(void) sd_device_monitor_set_receive_buffer_size(monitor, 128*1024*1024);
- r = sd_device_monitor_attach_event(monitor, event, 0);
+ r = sd_device_monitor_attach_event(monitor, event);
if (r < 0)
return log_error_errno(r, "Failed to attach event: %m");
@@ -84,10 +84,13 @@ static int setup_monitor(MonitorNetlinkGroup sender, sd_event *event, sd_device_
return log_error_errno(r, "Failed to apply tag filter '%s': %m", tag);
}
- r = sd_device_monitor_start(monitor, device_monitor_handler, INT_TO_PTR(sender), sender == MONITOR_GROUP_UDEV ? "device-monitor-udev" : "device-monitor-kernel");
+ r = sd_device_monitor_start(monitor, device_monitor_handler, INT_TO_PTR(sender));
if (r < 0)
return log_error_errno(r, "Failed to start device monitor: %m");
+ (void) sd_event_source_set_description(sd_device_monitor_get_event_source(monitor),
+ sender == MONITOR_GROUP_UDEV ? "device-monitor-udev" : "device-monitor-kernel");
+
*ret = TAKE_PTR(monitor);
return 0;
}
diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c
index 185fe29be0..38035b5c92 100644
--- a/src/udev/udevadm-trigger.c
+++ b/src/udev/udevadm-trigger.c
@@ -305,11 +305,11 @@ int trigger_main(int argc, char *argv[], void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to create device monitor object: %m");
- r = sd_device_monitor_attach_event(m, event, 0);
+ r = sd_device_monitor_attach_event(m, event);
if (r < 0)
return log_error_errno(r, "Failed to attach event to device monitor: %m");
- r = sd_device_monitor_start(m, device_monitor_handler, settle_set, "udevadm-trigger-device-monitor");
+ r = sd_device_monitor_start(m, device_monitor_handler, settle_set);
if (r < 0)
return log_error_errno(r, "Failed to start device monitor: %m");
}