OSDN Git Service

yet another race condition fix to address bug:2456970
authorVasu Nori <vnori@google.com>
Wed, 24 Feb 2010 20:42:46 +0000 (12:42 -0800)
committerVasu Nori <vnori@google.com>
Wed, 24 Feb 2010 20:42:46 +0000 (12:42 -0800)
core/java/android/database/sqlite/SQLiteProgram.java

index a3a8486..7a29cb4 100644 (file)
@@ -57,8 +57,10 @@ public abstract class SQLiteProgram extends SQLiteClosable {
             mCompiledSql = new SQLiteCompiledSql(db, sql);
 
             // add it to the cache of compiled-sqls
-            db.addToCompiledQueries(sql, mCompiledSql);
+            // but before adding it and thus making it available for anyone else to use it,
+            // make sure it is acquired by me.
             mCompiledSql.acquire();
+            db.addToCompiledQueries(sql, mCompiledSql);
         } else {
             // it is already in compiled-sql cache.
             // try to acquire the object.