if (r < 0)
return r;
+ r = sd_event_source_set_priority(worker->child_event_source, EVENT_PRIORITY_WORKER_SIGCHLD);
+ if (r < 0)
+ return r;
+
r = hashmap_ensure_put(&manager->workers, &worker_hash_op, &worker->pidref, worker);
if (r < 0)
return r;
if (r < 0)
return log_error_errno(r, "Failed to start device monitor: %m");
+ r = sd_event_source_set_priority(sd_device_monitor_get_event_source(manager->monitor), EVENT_PRIORITY_DEVICE_MONITOR);
+ if (r < 0)
+ return log_error_errno(r, "Failed to set priority to device monitor: %m");
+
return 0;
}
r = notify_socket_prepare(
manager->event,
- SD_EVENT_PRIORITY_NORMAL,
+ EVENT_PRIORITY_WORKER_NOTIFY,
on_worker_notify,
manager,
&manager->worker_notify_socket_path);
#include "udev-ctrl.h"
#include "udev-def.h"
+/* This must have a higher priority than the worker notification, to make IN_IGNORED event received earlier
+ * than notifications about requests of adding/removing inotify watches. */
+#define EVENT_PRIORITY_INOTIFY_WATCH (SD_EVENT_PRIORITY_NORMAL - 30)
+/* This must have a higher priority than the worker SIGCHLD event, to make notifications about completions of
+ * processing events received before SIGCHLD. */
+#define EVENT_PRIORITY_WORKER_NOTIFY (SD_EVENT_PRIORITY_NORMAL - 20)
+/* This should have a higher priority than other events, especially timer events about killing long running
+ * worker processes or idle worker processes. */
+#define EVENT_PRIORITY_WORKER_SIGCHLD (SD_EVENT_PRIORITY_NORMAL - 10)
+/* This should have a lower priority to make signal and timer event sources processed earlier. */
+#define EVENT_PRIORITY_DEVICE_MONITOR (SD_EVENT_PRIORITY_NORMAL + 10)
+
typedef struct Event Event;
typedef struct UdevRules UdevRules;
typedef struct Worker Worker;
if (r < 0)
return log_error_errno(r, "Failed to create inotify event source: %m");
+ r = sd_event_source_set_priority(s, EVENT_PRIORITY_INOTIFY_WATCH);
+ if (r < 0)
+ return log_error_errno(r, "Failed to set priority to inotify event source: %m");
+
(void) sd_event_source_set_description(s, "manager-inotify");
manager->inotify_event = TAKE_PTR(s);