Skip to content

Commit

Permalink
Merge pull request #474 from giuseppe/status-fix-race
Browse files Browse the repository at this point in the history
state: fix race condition when reading cgroup
  • Loading branch information
giuseppe authored Aug 27, 2020
2 parents 8bd4f3e + ed9c3e6 commit ee8746d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/libcrun/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -2194,7 +2194,17 @@ libcrun_get_container_state_string (const char *id, libcrun_container_status_t *

ret = libcrun_cgroup_is_container_paused (status->cgroup_path, cgroup_mode, &paused, err);
if (UNLIKELY (ret < 0))
return ret;
{
/* The cgroup might have been cleaned up by systemd by the time we try to read it, so ignore ENOENT. */
if (status->systemd_cgroup && crun_error_get_errno (err) == ENOENT)
{
crun_error_release (err);
*container_status = "stopped";
return 0;
}

return ret;
}
}

if (! *running)
Expand Down

0 comments on commit ee8746d

Please sign in to comment.