summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorDaniel Trebbien <dtrebbien@gmail.com>2010-10-31 13:45:02 -0700
committerSteve Kondik <shade@chemlab.org>2010-11-18 01:54:16 -0500
commite9b69c95aa3f833809df49aec5320a98d366d9d6 (patch)
treecefc7955f6b62358d2bef35b25f4510eb387bdce /core
parent65569cb8a7116307ccec63454ed0ade44abaaf95 (diff)
downloadframeworks_base-e9b69c95aa3f833809df49aec5320a98d366d9d6.zip
frameworks_base-e9b69c95aa3f833809df49aec5320a98d366d9d6.tar.gz
frameworks_base-e9b69c95aa3f833809df49aec5320a98d366d9d6.tar.bz2
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
Diffstat (limited to 'core')
-rw-r--r--core/java/android/database/sqlite/SQLiteCursor.java11
1 files changed, 5 insertions, 6 deletions
diff --git a/core/java/android/database/sqlite/SQLiteCursor.java b/core/java/android/database/sqlite/SQLiteCursor.java
index 6e5b3e1..39cbe5d 100644
--- a/core/java/android/database/sqlite/SQLiteCursor.java
+++ b/core/java/android/database/sqlite/SQLiteCursor.java
@@ -128,11 +128,11 @@ public class SQLiteCursor extends AbstractWindowedCursor {
// the cursor's state doesn't change
while (true) {
mLock.lock();
- if (mCursorState != mThreadState) {
- mLock.unlock();
- break;
- }
try {
+ if (mCursorState != mThreadState) {
+ break;
+ }
+
int count = mQuery.fillWindow(cw, mMaxRead, mCount);
// return -1 means not finished
if (count != 0) {
@@ -214,9 +214,8 @@ public class SQLiteCursor extends AbstractWindowedCursor {
mColumnNameMap = null;
mQuery = query;
+ db.lock();
try {
- db.lock();
-
// Setup the list of columns
int columnCount = mQuery.columnCountLocked();
mColumns = new String[columnCount];