summaryrefslogtreecommitdiff
path: root/src/udev/udevd.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-05-15 11:41:36 +0200
committerTom Gundersen <teg@jklm.no>2015-05-16 01:14:48 +0200
commit9a73bd7cab019aa1b9b4342ce2abd51b6e50b085 (patch)
tree3ea69c526c738b7daada46b6469cf80f06b69d8a /src/udev/udevd.c
parent8c7e28a191709f90736054e6f7844cf35b4ab93d (diff)
udevd: worker - use loop_write() rather than send()
When notifying the main daemon about event completion, make sure the message is sent successfully, and not interrupted.
Diffstat (limited to 'src/udev/udevd.c')
-rw-r--r--src/udev/udevd.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 318d769114..8142ec605d 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -221,6 +221,12 @@ static void worker_attach_event(struct worker *worker, struct event *event) {
event->worker = worker;
}
+static int worker_send_message(int fd) {
+ struct worker_message message = {};
+
+ return loop_write(fd, &message, sizeof(message), false);
+}
+
static void worker_spawn(Manager *manager, struct event *event) {
struct udev *udev = event->udev;
_cleanup_udev_monitor_unref_ struct udev_monitor *worker_monitor = NULL;
@@ -292,7 +298,6 @@ static void worker_spawn(Manager *manager, struct event *event) {
for (;;) {
struct udev_event *udev_event;
- struct worker_message msg;
int fd_lock = -1;
log_debug("seq %llu running", udev_device_get_seqnum(dev));
@@ -369,10 +374,9 @@ skip:
log_debug("seq %llu processed", udev_device_get_seqnum(dev));
/* send udevd the result of the event execution */
- memzero(&msg, sizeof(struct worker_message));
- r = send(worker_watch[WRITE_END], &msg, sizeof(struct worker_message), 0);
+ r = worker_send_message(worker_watch[WRITE_END]);
if (r < 0)
- log_error_errno(errno, "failed to send result of seq %llu to main daemon: %m",
+ log_error_errno(r, "failed to send result of seq %llu to main daemon: %m",
udev_device_get_seqnum(dev));
udev_device_unref(dev);