summaryrefslogtreecommitdiff
path: root/src/core/transaction.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-05-28 18:39:27 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-05-28 18:54:20 +0200
commita4ac27c1af5fa055a7c71729f71dce0b16cf5385 (patch)
treec1101dce6636a54f4c514c2dd3c5013934349565 /src/core/transaction.c
parentf6173cb955e85c485a2005f02651004d36c1fb57 (diff)
downloadsystemd-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/transaction.c')
-rw-r--r--src/core/transaction.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/core/transaction.c b/src/core/transaction.c
index 6f614a32dc..0fb52372f1 100644
--- a/src/core/transaction.c
+++ b/src/core/transaction.c
@@ -656,6 +656,10 @@ static int transaction_apply(
assert(!j->transaction_prev);
assert(!j->transaction_next);
+ r = hashmap_ensure_allocated(&m->jobs, NULL);
+ if (r < 0)
+ return r;
+
r = hashmap_put(m->jobs, UINT32_TO_PTR(j->id), j);
if (r < 0)
goto rollback;