mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 525356 - windows debug unit tests: test_connection_executeAsync.js and test_statement_executeAsync.js failing frequently (fatal assertion)
Make sure to release the database connection on the thread it was opened on, not the background thread! r=asuth a=beltzner
This commit is contained in:
parent
543fe93113
commit
9fc75352b9
@ -246,6 +246,7 @@ aggregateFunctionFinalHelper(sqlite3_context *aCtx)
|
||||
|
||||
Connection::Connection(Service *aService)
|
||||
: sharedAsyncExecutionMutex("Connection::sharedAsyncExecutionMutex")
|
||||
, threadOpenedOn(do_GetCurrentThread())
|
||||
, mDBConn(nsnull)
|
||||
, mAsyncExecutionMutex(nsAutoLock::NewLock("AsyncExecutionMutex"))
|
||||
, mAsyncExecutionThreadShuttingDown(PR_FALSE)
|
||||
|
@ -100,6 +100,11 @@ public:
|
||||
*/
|
||||
Mutex sharedAsyncExecutionMutex;
|
||||
|
||||
/**
|
||||
* References the thread this database was opened on.
|
||||
*/
|
||||
const nsCOMPtr<nsIThread> threadOpenedOn;
|
||||
|
||||
private:
|
||||
~Connection();
|
||||
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
#include "nsError.h"
|
||||
#include "nsMemory.h"
|
||||
#include "nsProxyRelease.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIClassInfoImpl.h"
|
||||
#include "nsIProgrammingLanguage.h"
|
||||
@ -77,18 +78,33 @@ namespace {
|
||||
class AsyncStatementFinalizer : public nsRunnable
|
||||
{
|
||||
public:
|
||||
AsyncStatementFinalizer(sqlite3_stmt *aStatement)
|
||||
/**
|
||||
* Constructor for the event.
|
||||
*
|
||||
* @param aStatement
|
||||
* The sqlite3_stmt to finalize on the background thread.
|
||||
* @param aConnection
|
||||
* The Connection that aStatement was created on. We hold a reference
|
||||
* to this to ensure that if we are the last reference to the
|
||||
* Connection, that we release it on the proper thread. The release
|
||||
* call is proxied to the appropriate thread.
|
||||
*/
|
||||
AsyncStatementFinalizer(sqlite3_stmt *aStatement,
|
||||
Connection *aConnection)
|
||||
: mStatement(aStatement)
|
||||
, mConnection(aConnection)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
(void)::sqlite3_finalize(mStatement);
|
||||
(void)::NS_ProxyRelease(mConnection->threadOpenedOn, mConnection);
|
||||
return NS_OK;
|
||||
}
|
||||
private:
|
||||
sqlite3_stmt *mStatement;
|
||||
nsCOMPtr<Connection> mConnection;
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
@ -401,7 +417,7 @@ Statement::Finalize()
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
new AsyncStatementFinalizer(mCachedAsyncStatement);
|
||||
new AsyncStatementFinalizer(mCachedAsyncStatement, mDBConnection);
|
||||
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsresult rv = target->Dispatch(event, NS_DISPATCH_NORMAL);
|
||||
|
Loading…
Reference in New Issue
Block a user