diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-05-28 18:39:27 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-05-28 18:54:20 +0200 |
commit | a4ac27c1af5fa055a7c71729f71dce0b16cf5385 (patch) | |
tree | c1101dce6636a54f4c514c2dd3c5013934349565 /src/core/job.c | |
parent | f6173cb955e85c485a2005f02651004d36c1fb57 (diff) | |
download | systemd-a4ac27c1af5fa055a7c71729f71dce0b16cf5385.tar.gz |
manager: free the jobs hashmap after we have no jobs
After a larger transaction, e.g. after bootup, we're left with an empty hashmap
with hundreds of buckets. Long-term, it'd be better to size hashmaps down when
they are less than 1/4 full, but even if we implement that, jobs hashmap is
likely to be empty almost always, so it seems useful to deallocate it once the
jobs count reaches 0.
Diffstat (limited to 'src/core/job.c')
-rw-r--r-- | src/core/job.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/core/job.c b/src/core/job.c index cf3bca88d6..d518ac8969 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -263,6 +263,10 @@ int job_install_deserialized(Job *j) { return log_unit_debug_errno(j->unit, SYNTHETIC_ERRNO(EEXIST), "Unit already has a job installed. Not installing deserialized job."); + r = hashmap_ensure_allocated(&j->manager->jobs, NULL); + if (r < 0) + return r; + r = hashmap_put(j->manager->jobs, UINT32_TO_PTR(j->id), j); if (r == -EEXIST) return log_unit_debug_errno(j->unit, r, "Job ID %" PRIu32 " already used, cannot deserialize job.", j->id); |