Bug 525356 - windows debug unit tests: test_connection_executeAsync.js and test_statement_executeAsync.js failing frequently (fatal assertion)

Release on the calling thread so when the connections destructor is called, it
is not on the background thread.
r=asuth
This commit is contained in:
Shawn Wilsher 2009-11-19 11:49:20 -08:00
parent 86b40d6c0d
commit 0d37582e30

View File

@ -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 aParent
* The object that owns aStatement. It will be released on the calling
* thread.
*/
AsyncStatementFinalizer(sqlite3_stmt *aStatement,
nsISupports *aParent)
: mStatement(aStatement)
, mParent(aParent)
, mCallingThread(do_GetCurrentThread())
{
}
NS_IMETHOD Run()
{
(void)::sqlite3_finalize(mStatement);
(void)::NS_ProxyRelease(mCallingThread, mParent);
return NS_OK;
}
private:
sqlite3_stmt *mStatement;
nsCOMPtr<nsISupports> mParent;
nsCOMPtr<nsIThread> mCallingThread;
};
} // anonymous namespace
@ -401,7 +417,7 @@ Statement::Finalize()
}
else {
nsCOMPtr<nsIRunnable> event =
new AsyncStatementFinalizer(mCachedAsyncStatement);
new AsyncStatementFinalizer(mCachedAsyncStatement, this);
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = target->Dispatch(event, NS_DISPATCH_NORMAL);