summaryrefslogtreecommitdiffstats
path: root/src/udev/udevd.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-12-18 07:03:50 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-01-12 01:32:20 +0100
commit956833b4170dcc957befb9009f5ea4a6dbd05e87 (patch)
tree9c1b3d4670227861b01e41abc8683db44eb8a271 /src/udev/udevd.c
parentudevd: use structured initializer at one more place (diff)
downloadsystemd-956833b4170dcc957befb9009f5ea4a6dbd05e87.tar.xz
systemd-956833b4170dcc957befb9009f5ea4a6dbd05e87.zip
udevd: provide worker_hash_ops and drop manager_workers_free()
Diffstat (limited to '')
-rw-r--r--src/udev/udevd.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 24f4824018..837e13e0dc 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -187,18 +187,7 @@ static void worker_free(struct worker *worker) {
}
DEFINE_TRIVIAL_CLEANUP_FUNC(struct worker *, worker_free);
-
-static void manager_workers_free(Manager *manager) {
- struct worker *worker;
- Iterator i;
-
- assert(manager);
-
- HASHMAP_FOREACH(worker, manager->workers, i)
- worker_free(worker);
-
- manager->workers = hashmap_free(manager->workers);
-}
+DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(worker_hash_op, void, trivial_hash_func, trivial_compare_func, struct worker, worker_free);
static int worker_new(struct worker **ret, Manager *manager, sd_device_monitor *worker_monitor, pid_t pid) {
_cleanup_(worker_freep) struct worker *worker = NULL;
@@ -222,7 +211,7 @@ static int worker_new(struct worker **ret, Manager *manager, sd_device_monitor *
.pid = pid,
};
- r = hashmap_ensure_allocated(&manager->workers, NULL);
+ r = hashmap_ensure_allocated(&manager->workers, &worker_hash_op);
if (r < 0)
return r;
@@ -296,7 +285,7 @@ static void manager_clear_for_worker(Manager *manager) {
manager->event = sd_event_unref(manager->event);
- manager_workers_free(manager);
+ manager->workers = hashmap_free(manager->workers);
event_queue_cleanup(manager, EVENT_UNDEF);
manager->monitor = sd_device_monitor_unref(manager->monitor);