udev: split out device_broadcast_on_error()
This commit is contained in:
+23
-2
@@ -1,8 +1,8 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "device-monitor-private.h"
|
||||
#include "device-private.h"
|
||||
#include "device-util.h"
|
||||
#include "errno-list.h"
|
||||
#include "errno-util.h"
|
||||
#include "signal-util.h"
|
||||
@@ -54,3 +54,24 @@ int device_add_signal(sd_device *dev, int signo) {
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int device_broadcast_on_error(sd_device *dev, sd_device_monitor *monitor) {
|
||||
int r;
|
||||
|
||||
assert(dev);
|
||||
assert(monitor);
|
||||
|
||||
/* delete state from disk */
|
||||
(void) device_delete_db(dev);
|
||||
(void) device_tag_index(dev, /* device_old = */ NULL, /* add = */ false);
|
||||
|
||||
r = device_monitor_send(monitor, /* destination = */ NULL, dev);
|
||||
if (r < 0) {
|
||||
uint64_t seqnum = 0;
|
||||
|
||||
(void) sd_device_get_seqnum(dev, &seqnum);
|
||||
return log_device_warning_errno(dev, r, "Failed to broadcast event (SEQNUM=%"PRIu64") to libudev listeners: %m", seqnum);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -6,3 +6,4 @@
|
||||
int device_add_errno(sd_device *dev, int error);
|
||||
int device_add_exit_status(sd_device *dev, int status);
|
||||
int device_add_signal(sd_device *dev, int signo);
|
||||
int device_broadcast_on_error(sd_device *dev, sd_device_monitor *monitor);
|
||||
|
||||
@@ -353,7 +353,6 @@ void manager_revert(Manager *manager) {
|
||||
static int on_sigchld(sd_event_source *s, const siginfo_t *si, void *userdata) {
|
||||
_cleanup_(worker_freep) Worker *worker = ASSERT_PTR(userdata);
|
||||
sd_device *dev = worker->event ? ASSERT_PTR(worker->event->dev) : NULL;
|
||||
int r;
|
||||
|
||||
assert(si);
|
||||
|
||||
@@ -386,14 +385,7 @@ static int on_sigchld(sd_event_source *s, const siginfo_t *si, void *userdata) {
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
/* delete state from disk */
|
||||
device_delete_db(dev);
|
||||
device_tag_index(dev, NULL, false);
|
||||
|
||||
r = device_monitor_send(worker->manager->monitor, NULL, dev);
|
||||
if (r < 0)
|
||||
log_device_warning_errno(dev, r, "Failed to broadcast event to libudev listeners, ignoring: %m");
|
||||
|
||||
(void) device_broadcast_on_error(dev, worker->manager->monitor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user