]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevd: worker - log if worker result cannot be sent
authorTom Gundersen <teg@jklm.no>
Fri, 24 Apr 2015 18:36:02 +0000 (20:36 +0200)
committerTom Gundersen <teg@jklm.no>
Fri, 24 Apr 2015 18:36:05 +0000 (20:36 +0200)
If the main daemon is not notified about a worker finishing an event
the refcounting of the worker struct will be wrong, and we will lose
track of the number of children we have to wait for.

This should not happen, but if it does we better complain loudly about
it. Worst case udev will wait for 30 seconsd at shutdown waiting for
nonexistent workers.

src/udev/udevd.c

index 339e9c45709db584a5e591f8234742988e195865..365bb00a7fc0cdcca9bbbf560b11e37439600aa9 100644 (file)
@@ -255,7 +255,7 @@ static void worker_new(struct event *event) {
                         struct udev_event *udev_event;
                         struct worker_message msg;
                         int fd_lock = -1;
-                        int err = 0;
+                        int err = 0, r;
 
                         log_debug("seq %llu running", udev_device_get_seqnum(dev));
                         udev_event = udev_event_new(dev);
@@ -328,12 +328,15 @@ static void worker_new(struct event *event) {
                         udev_monitor_send_device(worker_monitor, NULL, dev);
 
 skip:
+                        log_debug("seq %llu processed with %i", udev_device_get_seqnum(dev), err);
+
                         /* send udevd the result of the event execution */
                         memzero(&msg, sizeof(struct worker_message));
                         msg.exitcode = err;
-                        send(worker_watch[WRITE_END], &msg, sizeof(struct worker_message), 0);
-
-                        log_debug("seq %llu processed with %i", udev_device_get_seqnum(dev), err);
+                        r = send(worker_watch[WRITE_END], &msg, sizeof(struct worker_message), 0);
+                        if (r < 0)
+                                log_error_errno(errno, "failed to send result of seq %llu to main daemon: %m",
+                                                udev_device_get_seqnum(dev));
 
                         udev_device_unref(dev);
                         dev = NULL;