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

Commit b1c1f9a7 authored by Christopher Tate's avatar Christopher Tate
Browse files

Fix job duplication bug

Lookup of an existing obsoleted job was not done within the same
lock lifetime as scheduling its replacement, which means that callers
could race scheduling "the same" job and wind up creating duplicates.

Bug 27589164

Change-Id: I572b01092964b82316961de601bb7f1afedf18de
parent 54f4a630
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -311,11 +311,11 @@ public final class JobSchedulerService extends com.android.server.SystemService
            }

            toCancel = mJobs.getJobByUidAndJobId(uId, job.getId());
        }
        startTrackingJob(jobStatus, toCancel);
            if (toCancel != null) {
                cancelJobImpl(toCancel);
            }
            startTrackingJob(jobStatus, toCancel);
        }
        mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
        return JobScheduler.RESULT_SUCCESS;
    }