sm6375-common: power-libperfmgr: Fix race condition between Looper and destructor
1. Clean all messages before add new. 2. Insteading of using `this`, use the unique mStaleHandler sp so Looper can hold the sp to keep the instance alive until the last message done. Test: Manual Test Bug: 219965773 Change-Id: Ic039146f0b966c1f27d86b121d4b72b75ff360e5
This commit is contained in:
parent
4bdcfc21e1
commit
e943cbd1a8
2 changed files with 36 additions and 5 deletions
|
|
@ -86,16 +86,21 @@ class PowerHintSession : public BnPowerHintSession {
|
|||
class StaleHandler : public MessageHandler {
|
||||
public:
|
||||
StaleHandler(PowerHintSession *session)
|
||||
: mSession(session), mIsMonitoringStale(false), mLastUpdatedTime(steady_clock::now()) {}
|
||||
: mSession(session),
|
||||
mIsMonitoringStale(false),
|
||||
mLastUpdatedTime(steady_clock::now()),
|
||||
mIsSessionDead(false) {}
|
||||
void handleMessage(const Message &message) override;
|
||||
void updateStaleTimer();
|
||||
time_point<steady_clock> getStaleTime();
|
||||
void setSessionDead();
|
||||
|
||||
private:
|
||||
PowerHintSession *mSession;
|
||||
std::atomic<bool> mIsMonitoringStale;
|
||||
std::atomic<time_point<steady_clock>> mLastUpdatedTime;
|
||||
std::mutex mStaleLock;
|
||||
bool mIsSessionDead;
|
||||
};
|
||||
|
||||
private:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue