mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-03 22:38:41 +09:00
Issue #2672 - Part 2: Auto-close syncConn for edge cases.
This commit is contained in:
parent
aec27853c6
commit
fe53a0bb1c
1 changed files with 7 additions and 2 deletions
|
|
@ -49,6 +49,7 @@
|
|||
#include "mozilla/storage.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
#include "mozilla/FileUtils.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsVariant.h"
|
||||
|
||||
|
|
@ -845,6 +846,10 @@ nsCookieService::TryInitDB(bool aRecreateDB)
|
|||
getter_AddRefs(mDefaultDBState->syncConn));
|
||||
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
|
||||
|
||||
auto guard = MakeScopeExit([&] {
|
||||
mDefaultDBState->syncConn = nullptr;
|
||||
});
|
||||
|
||||
bool tableExists = false;
|
||||
mDefaultDBState->syncConn->TableExists(NS_LITERAL_CSTRING("moz_cookies"),
|
||||
&tableExists);
|
||||
|
|
@ -1596,8 +1601,8 @@ nsCookieService::CleanupDefaultDBConnection()
|
|||
// Null out the database connections. If 'dbConn' has not been used for any
|
||||
// asynchronous operations yet, this will synchronously close it; otherwise,
|
||||
// it's expected that the caller has performed an AsyncClose prior.
|
||||
// Note 'syncConn' is auto-closed on scope exit.
|
||||
mDefaultDBState->dbConn = nullptr;
|
||||
mDefaultDBState->syncConn = nullptr;
|
||||
|
||||
// Manually null out our listeners. This is necessary because they hold a
|
||||
// strong ref to the DBState itself. They'll stay alive until whatever
|
||||
|
|
@ -2619,7 +2624,7 @@ nsCookieService::Read()
|
|||
tuple->cookie = GetCookieFromRow(stmt, attrs);
|
||||
}
|
||||
|
||||
mDefaultDBState->syncConn = nullptr;
|
||||
// Note: 'syncConn' is auto-closed on scope exit.
|
||||
|
||||
COOKIE_LOGSTRING(LogLevel::Debug, ("Read(): %zu cookies read", mReadArray.Length()));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue