diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-11-06 02:03:04 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-11-06 02:31:35 +0100 |
commit | d3e84ddb885e9d5f0ae9930eb905910e3a81f157 (patch) | |
tree | 06f15d176ed35af4b825e901e73d8c8629473963 /src/machine/machine.c | |
parent | cd6f997f71c3aba16aa08226d423d14cbc787f82 (diff) |
machined: keep track of the initial leader PID of a machine
This way we can without races always determine the machine for a leader
PID. This allows machine managers to query the machine for a forked off
container/VM without a race where the child might already have died
before we could read the cgroup information from /proc/$PID/cgroup.
Diffstat (limited to 'src/machine/machine.c')
-rw-r--r-- | src/machine/machine.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/machine/machine.c b/src/machine/machine.c index a33a111043..cf3ef15456 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -85,6 +85,9 @@ void machine_free(Machine *m) { hashmap_remove(m->manager->machines, m->name); + if (m->leader > 0) + hashmap_remove_value(m->manager->machine_leaders, UINT_TO_PTR(m->leader), m); + sd_bus_message_unref(m->create_message); free(m->name); @@ -263,6 +266,10 @@ int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error) { if (m->started) return 0; + r = hashmap_put(m->manager->machine_leaders, UINT_TO_PTR(m->leader), m); + if (r < 0) + return r; + /* Create cgroup */ r = machine_start_scope(m, properties, error); if (r < 0) |