Bug 505550 - Acquire the db's mutex when cloning statements in Connection::ExecuteAsync

Hold the lock around all our API calls so we don't lose so much to the
background thread.
r=asuth
This commit is contained in:
Shawn Wilsher 2009-07-22 15:18:33 -07:00
parent 5a66fb8a7c
commit 6631ab6c3b

View File

@ -630,6 +630,8 @@ Connection::ExecuteAsync(mozIStorageStatement **aStatements,
{
int rc = SQLITE_OK;
nsTArray<StatementData> stmts(aNumStatements);
{
SQLiteMutexAutoLock lockedScope(mDBMutex);
for (PRUint32 i = 0; i < aNumStatements && rc == SQLITE_OK; i++) {
sqlite3_stmt *old_stmt =
static_cast<Statement *>(aStatements[i])->nativeStatement();
@ -665,7 +667,8 @@ Connection::ExecuteAsync(mozIStorageStatement **aStatements,
rc = SQLITE_NOMEM;
break;
}
}
} // for loop
} // locked Scope
// Dispatch to the background
nsresult rv = NS_OK;
@ -682,8 +685,11 @@ Connection::ExecuteAsync(mozIStorageStatement **aStatements,
}
// Always reset all the statements
{
SQLiteMutexAutoLock lockedScope(mDBMutex);
for (PRUint32 i = 0; i < aNumStatements; i++)
(void)aStatements[i]->Reset();
}
return rv;
}