Reland "libprocessgroup: return false on failure"

This reverts commit c109b13b5a.

Reason for revert: uploading with a CL fixing the broken test

Change-Id: I97a0a49ded8bc17c2d70c82f8e48fce09e49b2bd
This commit is contained in:
Inseob Kim 2022-04-13 18:50:12 +00:00
parent c109b13b5a
commit 538fc1fab1
1 changed files with 10 additions and 4 deletions

View File

@ -806,6 +806,7 @@ const IProfileAttribute* TaskProfiles::GetAttribute(const std::string& name) con
bool TaskProfiles::SetProcessProfiles(uid_t uid, pid_t pid, bool TaskProfiles::SetProcessProfiles(uid_t uid, pid_t pid,
const std::vector<std::string>& profiles, bool use_fd_cache) { const std::vector<std::string>& profiles, bool use_fd_cache) {
bool success = true;
for (const auto& name : profiles) { for (const auto& name : profiles) {
TaskProfile* profile = GetProfile(name); TaskProfile* profile = GetProfile(name);
if (profile != nullptr) { if (profile != nullptr) {
@ -814,16 +815,19 @@ bool TaskProfiles::SetProcessProfiles(uid_t uid, pid_t pid,
} }
if (!profile->ExecuteForProcess(uid, pid)) { if (!profile->ExecuteForProcess(uid, pid)) {
PLOG(WARNING) << "Failed to apply " << name << " process profile"; PLOG(WARNING) << "Failed to apply " << name << " process profile";
success = false;
} }
} else { } else {
PLOG(WARNING) << "Failed to find " << name << "process profile"; PLOG(WARNING) << "Failed to find " << name << " process profile";
success = false;
} }
} }
return true; return success;
} }
bool TaskProfiles::SetTaskProfiles(int tid, const std::vector<std::string>& profiles, bool TaskProfiles::SetTaskProfiles(int tid, const std::vector<std::string>& profiles,
bool use_fd_cache) { bool use_fd_cache) {
bool success = true;
for (const auto& name : profiles) { for (const auto& name : profiles) {
TaskProfile* profile = GetProfile(name); TaskProfile* profile = GetProfile(name);
if (profile != nullptr) { if (profile != nullptr) {
@ -832,10 +836,12 @@ bool TaskProfiles::SetTaskProfiles(int tid, const std::vector<std::string>& prof
} }
if (!profile->ExecuteForTask(tid)) { if (!profile->ExecuteForTask(tid)) {
PLOG(WARNING) << "Failed to apply " << name << " task profile"; PLOG(WARNING) << "Failed to apply " << name << " task profile";
success = false;
} }
} else { } else {
PLOG(WARNING) << "Failed to find " << name << "task profile"; PLOG(WARNING) << "Failed to find " << name << " task profile";
success = false;
} }
} }
return true; return success;
} }