From 0391e09260b0d036ca1a4c1df6ab8fb55ff65c8b Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Thu, 2 Jun 2011 10:00:51 +0000 Subject: [PATCH] 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 --- checkin_notes | 8 ++++++++ clientgui/browser.cpp | 30 ++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/checkin_notes b/checkin_notes index efd9f6d998..7267bcd418 100644 --- a/checkin_notes +++ b/checkin_notes @@ -3237,3 +3237,11 @@ Charlie 2 Jun 2011 mac_build/ boinc.xcodeproj/ 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 diff --git a/clientgui/browser.cpp b/clientgui/browser.cpp index efd20e8f67..1ee4921132 100644 --- a/clientgui/browser.cpp +++ b/clientgui/browser.cpp @@ -30,6 +30,7 @@ #include "mfile.h" #include "miofile.h" #include "str_util.h" +#include "filesys.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 ) { bool retval = false; - std::string tmp; + bool firstpass = true; + std::string cookieFilePath; + std::string cookieCopyFilePath; std::string hostname; char query[1024]; sqlite3* db; @@ -618,11 +621,13 @@ bool detect_cookie_mozilla_v3( // now we should open up the cookie database. - tmp = profile_root + "cookies.sqlite"; - rc = sqlite3_open(tmp.c_str(), &db); + cookieFilePath = profile_root + "cookies.sqlite"; +retry: + rc = sqlite3_open(cookieFilePath.c_str(), &db); if ( rc ) { sqlite3_close(db); - return false; + retval = false; + goto cleanUpCopy; } // construct SQL query to extract the desired cookie @@ -642,11 +647,28 @@ bool detect_cookie_mozilla_v3( // cleanup 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() ) { value = cookie.value; retval = true; } +cleanUpCopy: + if (!firstpass) { + boinc_delete_file(cookieCopyFilePath.c_str()); + } + return retval; }