MGR: If Firefox 3 SQL query fails because cookie database is locked, make a temporary copy of the cookie file and query that

svn path=/trunk/boinc/; revision=23629
This commit is contained in:
Charlie Fenton 2011-06-02 10:00:51 +00:00
parent 62b379eeaa
commit 0391e09260
2 changed files with 34 additions and 4 deletions

View File

@ -3237,3 +3237,11 @@ Charlie 2 Jun 2011
mac_build/ mac_build/
boinc.xcodeproj/ boinc.xcodeproj/
project.pbxproj project.pbxproj
Charlie 2 Jun 2011
- MGR: If Firefox 3 SQL query fails because cookie database is locked,
make a temporary copy of the cookie file and query that. This works
around a bug in some builds of Firefox 3.5.x.
clientgui/
browser.cpp

View File

@ -30,6 +30,7 @@
#include "mfile.h" #include "mfile.h"
#include "miofile.h" #include "miofile.h"
#include "str_util.h" #include "str_util.h"
#include "filesys.h"
#include "browser.h" #include "browser.h"
@ -600,7 +601,9 @@ bool detect_cookie_mozilla_v3(
std::string profile_root, std::string& project_url, std::string& name, std::string& value std::string profile_root, std::string& project_url, std::string& name, std::string& value
) { ) {
bool retval = false; bool retval = false;
std::string tmp; bool firstpass = true;
std::string cookieFilePath;
std::string cookieCopyFilePath;
std::string hostname; std::string hostname;
char query[1024]; char query[1024];
sqlite3* db; sqlite3* db;
@ -618,11 +621,13 @@ bool detect_cookie_mozilla_v3(
// now we should open up the cookie database. // now we should open up the cookie database.
tmp = profile_root + "cookies.sqlite"; cookieFilePath = profile_root + "cookies.sqlite";
rc = sqlite3_open(tmp.c_str(), &db); retry:
rc = sqlite3_open(cookieFilePath.c_str(), &db);
if ( rc ) { if ( rc ) {
sqlite3_close(db); sqlite3_close(db);
return false; retval = false;
goto cleanUpCopy;
} }
// construct SQL query to extract the desired cookie // construct SQL query to extract the desired cookie
@ -642,11 +647,28 @@ bool detect_cookie_mozilla_v3(
// cleanup // cleanup
sqlite3_close(db); sqlite3_close(db);
if (((rc == SQLITE_BUSY) || (rc == SQLITE_LOCKED)) && firstpass) {
firstpass = false;
cookieCopyFilePath = profile_root + "boinc_cookies.sqlite";
rc = boinc_copy(cookieFilePath.c_str(), cookieCopyFilePath.c_str());
if (rc) {
retval = false;
goto cleanUpCopy;
}
cookieFilePath = cookieCopyFilePath;
goto retry;
}
if ( !cookie.value.empty() ) { if ( !cookie.value.empty() ) {
value = cookie.value; value = cookie.value;
retval = true; retval = true;
} }
cleanUpCopy:
if (!firstpass) {
boinc_delete_file(cookieCopyFilePath.c_str());
}
return retval; return retval;
} }