зеркало из https://github.com/mozilla/gecko-dev.git
Bug 434805: work harder to recover from url-classifier db corruption. r=tony
This commit is contained in:
Родитель
9a7bd7aff0
Коммит
735c08486e
|
@ -31,6 +31,7 @@ CPPSRCS = \
|
||||||
|
|
||||||
LOCAL_INCLUDES = \
|
LOCAL_INCLUDES = \
|
||||||
-I$(srcdir)/../../build \
|
-I$(srcdir)/../../build \
|
||||||
|
$(SQLITE_CFLAGS) \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,9 @@
|
||||||
#include "prnetdb.h"
|
#include "prnetdb.h"
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
|
|
||||||
|
// Needed to interpert mozIStorageConnection::GetLastError
|
||||||
|
#include <sqlite3.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DBServices stores a set of Fragments. A fragment is one URL
|
* The DBServices stores a set of Fragments. A fragment is one URL
|
||||||
* fragment containing two or more domain components and some number
|
* fragment containing two or more domain components and some number
|
||||||
|
@ -3056,6 +3059,11 @@ nsUrlClassifierDBServiceWorker::FinishUpdate()
|
||||||
NS_ENSURE_STATE(!mInStream);
|
NS_ENSURE_STATE(!mInStream);
|
||||||
NS_ENSURE_STATE(mUpdateObserver);
|
NS_ENSURE_STATE(mUpdateObserver);
|
||||||
|
|
||||||
|
// We need to get the error code before ApplyUpdate, because it might
|
||||||
|
// close/open the connection.
|
||||||
|
PRInt32 errcode = SQLITE_OK;
|
||||||
|
mConnection->GetLastError(&errcode);
|
||||||
|
|
||||||
ApplyUpdate();
|
ApplyUpdate();
|
||||||
|
|
||||||
if (NS_SUCCEEDED(mUpdateStatus)) {
|
if (NS_SUCCEEDED(mUpdateStatus)) {
|
||||||
|
@ -3064,7 +3072,13 @@ nsUrlClassifierDBServiceWorker::FinishUpdate()
|
||||||
mUpdateObserver->UpdateError(mUpdateStatus);
|
mUpdateObserver->UpdateError(mUpdateStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mResetRequested) {
|
// It's important that we only reset the database on an update
|
||||||
|
// command if the update was successful, otherwise unauthenticated
|
||||||
|
// updates could cause a database reset.
|
||||||
|
PRBool resetDB = (NS_SUCCEEDED(mUpdateStatus) && mResetRequested) ||
|
||||||
|
errcode == SQLITE_CORRUPT;
|
||||||
|
|
||||||
|
if (!resetDB) {
|
||||||
if (NS_SUCCEEDED(mUpdateStatus)) {
|
if (NS_SUCCEEDED(mUpdateStatus)) {
|
||||||
PRInt64 now = (PR_Now() / PR_USEC_PER_SEC);
|
PRInt64 now = (PR_Now() / PR_USEC_PER_SEC);
|
||||||
for (PRUint32 i = 0; i < mUpdateTables.Length(); i++) {
|
for (PRUint32 i = 0; i < mUpdateTables.Length(); i++) {
|
||||||
|
@ -3079,15 +3093,9 @@ nsUrlClassifierDBServiceWorker::FinishUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetUpdate() clears mResetRequested...
|
|
||||||
PRBool resetRequested = mResetRequested;
|
|
||||||
|
|
||||||
ResetUpdate();
|
ResetUpdate();
|
||||||
|
|
||||||
// It's important that we only reset the database if the update was
|
if (resetDB) {
|
||||||
// successful, otherwise unauthenticated updates could cause a
|
|
||||||
// database reset.
|
|
||||||
if (NS_SUCCEEDED(mUpdateStatus) && resetRequested) {
|
|
||||||
ResetDatabase();
|
ResetDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче