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

Commit 38767b34 authored by Daniel Trebbien's avatar Daniel Trebbien Committed by Jean-Baptiste Queru
Browse files

Reorder lock acquision vs try.

In two places involving locking, reordered the code so that the lock
acquisition is performed outside of the `try` block and everything
else that needs to run while the lock is locked *within* the `try`
block.

Change-Id: I3dad2c4bbf60b219fc6db2aa35e2ed296cb39128
parent cee8d1d3
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -131,11 +131,11 @@ public class SQLiteCursor extends AbstractWindowedCursor {
            // the cursor's state doesn't change
            while (true) {
                mLock.lock();
                try {
                    if (mCursorState != mThreadState) {
                    mLock.unlock();
                        break;
                    }
                try {

                    int count = mQuery.fillWindow(cw, mMaxRead, mCount);
                    // return -1 means not finished
                    if (count != 0) {
@@ -217,9 +217,8 @@ public class SQLiteCursor extends AbstractWindowedCursor {
        mColumnNameMap = null;
        mQuery = query;

        try {
        db.lock();

        try {
            // Setup the list of columns
            int columnCount = mQuery.columnCountLocked();
            mColumns = new String[columnCount];