Disable SetupCgroup for non-Android targets

Non-android targets should not mount cgroups described in cgroup map
file. When used on non-Android targets SetupCgroup will fail. When
SetupCgroup is called via SetupCgroups a warning will be generated for
each cgroup that fails to mount.

Bug: 111307099
Change-Id: I213a5f9b02f312ba1dd7dc91c89b67334fb939b9
Merged-In: I213a5f9b02f312ba1dd7dc91c89b67334fb939b9
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
Suren Baghdasaryan 2019-02-02 23:12:01 -08:00
parent eca87cb9ca
commit ff25a5f584
1 changed files with 12 additions and 0 deletions

View File

@ -142,6 +142,9 @@ static bool ReadDescriptors(std::map<std::string, CgroupDescriptor>* descriptors
return true;
}
// To avoid issues in sdk_mac build
#if defined(__ANDROID__)
static bool SetupCgroup(const CgroupDescriptor& descriptor) {
const CgroupController* controller = descriptor.controller();
@ -180,6 +183,15 @@ static bool SetupCgroup(const CgroupDescriptor& descriptor) {
return true;
}
#else
// Stubs for non-Android targets.
static bool SetupCgroup(const CgroupDescriptor&) {
return false;
}
#endif
static bool WriteRcFile(const std::map<std::string, CgroupDescriptor>& descriptors) {
std::string cgroup_rc_path = StringPrintf("%s/%s", CGROUPS_RC_DIR, CgroupMap::CGROUPS_RC_FILE);
unique_fd fd(TEMP_FAILURE_RETRY(open(cgroup_rc_path.c_str(),