udev: adjust event source priorities
This commit is contained in:
@@ -189,6 +189,10 @@ static int worker_new(Worker **ret, Manager *manager, sd_device_monitor *worker_
|
||||
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;
|
||||
@@ -1123,6 +1127,10 @@ static int manager_start_device_monitor(Manager *manager) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1134,7 +1142,7 @@ static int manager_start_worker_notify(Manager *manager) {
|
||||
|
||||
r = notify_socket_prepare(
|
||||
manager->event,
|
||||
SD_EVENT_PRIORITY_NORMAL,
|
||||
EVENT_PRIORITY_WORKER_NOTIFY,
|
||||
on_worker_notify,
|
||||
manager,
|
||||
&manager->worker_notify_socket_path);
|
||||
|
||||
@@ -14,6 +14,18 @@
|
||||
#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;
|
||||
|
||||
@@ -386,6 +386,10 @@ int manager_start_inotify(Manager *manager) {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user