summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorVasu Nori <vnori@google.com>2010-10-05 12:27:27 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-10-05 12:27:27 -0700
commit54f9ac5880a33c8cd66ccb8930b175d1aca2a6f8 (patch)
treeab2d0b6a6b05574c295f3b27b75d4aebe32b150d /core
parent3d535d29496d10b5528d0c5a228d1d798e00735a (diff)
parent6d970255af55443a1c9a4211be9a265408598680 (diff)
downloadframeworks_base-54f9ac5880a33c8cd66ccb8930b175d1aca2a6f8.zip
frameworks_base-54f9ac5880a33c8cd66ccb8930b175d1aca2a6f8.tar.gz
frameworks_base-54f9ac5880a33c8cd66ccb8930b175d1aca2a6f8.tar.bz2
Merge "STOPSHIP - add illegalStateException to catch potential deadlocks in db"
Diffstat (limited to 'core')
-rw-r--r--core/java/android/database/sqlite/SQLiteDatabase.java21
1 files changed, 10 insertions, 11 deletions
diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java
index f0d0fb4..a98a305 100644
--- a/core/java/android/database/sqlite/SQLiteDatabase.java
+++ b/core/java/android/database/sqlite/SQLiteDatabase.java
@@ -410,8 +410,16 @@ public class SQLiteDatabase extends SQLiteClosable {
* @see #unlock()
*/
/* package */ void lock() {
+ lock(false);
+ }
+ private void lock(boolean forced) {
+ // make sure this method is NOT being called from a 'synchronized' method
+ if (Thread.holdsLock(this)) {
+ // STOPSHIP change the following line to Log.w()
+ throw new IllegalStateException("don't lock() while in a synchronized method");
+ }
verifyDbIsOpen();
- if (!mLockingEnabled) return;
+ if (!forced && !mLockingEnabled) return;
mLock.lock();
if (SQLiteDebug.DEBUG_LOCK_TIME_TRACKING) {
if (mLock.getHoldCount() == 1) {
@@ -421,7 +429,6 @@ public class SQLiteDatabase extends SQLiteClosable {
}
}
}
-
/**
* Locks the database for exclusive access. The database lock must be held when
* touch the native sqlite3* object since it is single threaded and uses
@@ -431,15 +438,7 @@ public class SQLiteDatabase extends SQLiteClosable {
* @see #unlockForced()
*/
private void lockForced() {
- verifyDbIsOpen();
- mLock.lock();
- if (SQLiteDebug.DEBUG_LOCK_TIME_TRACKING) {
- if (mLock.getHoldCount() == 1) {
- // Use elapsed real-time since the CPU may sleep when waiting for IO
- mLockAcquiredWallTime = SystemClock.elapsedRealtime();
- mLockAcquiredThreadTime = Debug.threadCpuTimeNanos();
- }
- }
+ lock(true);
}
/**