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

Commit 1d08e599 authored by Jean-Christophe PINCE's avatar Jean-Christophe PINCE Committed by Michael Wright
Browse files

Watchdog race condition when sending message out of synchronized



A race condition leading to false positive detections might occur
when the monitoring thread executes very fast and terminates before
the sending thread entered the synchronized section.

Change-Id: I6fe686f8f12393e11fa18326508af5b73738f9d7
Author: Jean-Christophe PINCE <jean-christophe.pince@intel.com>
Signed-off-by: default avatarJean-Christophe PINCE <jean-christophe.pince@intel.com>
Signed-off-by: default avatarShuo Gao <shuo.gao@intel.com>
Signed-off-by: default avatarBruce Beare <bruce.j.beare@intel.com>
Signed-off-by: default avatarJack Ren <jack.ren@intel.com>
Author-tracking-BZ: 81644
parent 6c825d49
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -386,13 +386,11 @@ public class Watchdog extends Thread {
    public void run() {
        boolean waitedHalf = false;
        while (true) {
            mCompleted = false;
            mHandler.sendEmptyMessage(MONITOR);


            final String name;
            synchronized (this) {
                long timeout = TIME_TO_WAIT;
                mCompleted = false;
                mHandler.sendEmptyMessage(MONITOR);

                // NOTE: We use uptimeMillis() here because we do not want to increment the time we
                // wait while asleep. If the device is asleep then the thing that we are waiting