Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5562b076 authored by Suren Baghdasaryan's avatar Suren Baghdasaryan Committed by Gerrit Code Review
Browse files

Merge "libprocessgroup: Prevent aggregate profiles from referencing stale ones"

parents 347d6406 8438595f
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -288,6 +288,11 @@ bool ApplyProfileAction::ExecuteForTask(int tid) const {
    return true;
}

void TaskProfile::MoveTo(TaskProfile* profile) {
    profile->elements_ = std::move(elements_);
    profile->res_cached_ = res_cached_;
}

bool TaskProfile::ExecuteForProcess(uid_t uid, pid_t pid) const {
    for (const auto& element : elements_) {
        if (!element->ExecuteForProcess(uid, pid)) {
@@ -458,7 +463,15 @@ bool TaskProfiles::Load(const CgroupMap& cg_map, const std::string& file_name) {
                LOG(WARNING) << "Unknown profile action: " << action_name;
            }
        }
        auto iter = profiles_.find(profile_name);
        if (iter == profiles_.end()) {
            profiles_[profile_name] = profile;
        } else {
            // Move the content rather that replace the profile because old profile might be
            // referenced from an aggregate profile if vendor overrides task profiles
            profile->MoveTo(iter->second.get());
            profile.reset();
        }
    }

    const Json::Value& aggregateprofiles_val = root["AggregateProfiles"];
+1 −0
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ class TaskProfile {
    TaskProfile() : res_cached_(false) {}

    void Add(std::unique_ptr<ProfileAction> e) { elements_.push_back(std::move(e)); }
    void MoveTo(TaskProfile* profile);

    bool ExecuteForProcess(uid_t uid, pid_t pid) const;
    bool ExecuteForTask(int tid) const;