mirror of https://github.com/BOINC/boinc.git
Mac MGR: Fix per-thread-locale logic on Mac; weak-link sqlite3 for OS 10.3.9 compatibility.
svn path=/trunk/boinc/; revision=18257
This commit is contained in:
parent
8333c35c81
commit
f47ae35b4d
|
@ -4893,3 +4893,11 @@ David 1 June 2009
|
|||
sched/
|
||||
feeder.cpp
|
||||
main.cpp
|
||||
|
||||
Charlie 1 June 2009
|
||||
- Mac MGR: Fix per-thread-locale logic on Mac.
|
||||
- Mac MGR: Mac OS 10.3.9 does not have sqlite3, so we must weak-link.
|
||||
|
||||
clientgui/
|
||||
AsyncRPC.cpp
|
||||
browser.cpp
|
||||
|
|
|
@ -129,25 +129,27 @@ void *RPCThread::Entry() {
|
|||
ASYNC_RPC_REQUEST *current_request;
|
||||
wxMutexError mutexErr = wxMUTEX_NO_ERROR;
|
||||
wxCondError condErr = wxCOND_NO_ERROR;
|
||||
|
||||
m_pRPC_Thread_Mutex->Lock();
|
||||
|
||||
#ifndef NO_PER_THREAD_LOCALE
|
||||
#ifdef __WXMSW__
|
||||
// On Windows, set all locales for this thread on a per-thread basis
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
setlocale(LC_ALL, "C");
|
||||
#elif defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4)
|
||||
if (uselocale) { // uselocale() is not available in Mac OS 10.3.9
|
||||
locale_t RPC_Thread_Locale = newlocale(LC_ALL_MASK, NULL, NULL);
|
||||
#else
|
||||
// We initialize RPC_Thread_Locale to fix a compiler warning
|
||||
locale_t RPC_Thread_Locale = LC_GLOBAL_LOCALE;
|
||||
#if defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4)
|
||||
if (uselocale) // uselocale() is not available in Mac OS 10.3.9
|
||||
#endif
|
||||
{
|
||||
// On Mac / Unix / Linux, set "C" locale for this thread only
|
||||
RPC_Thread_Locale = newlocale(LC_ALL_MASK, NULL, NULL);
|
||||
uselocale(RPC_Thread_Locale);
|
||||
}
|
||||
#else
|
||||
// On Mac / Unix / Linux, set "C" locale for this thread only
|
||||
locale_t RPC_Thread_Locale = newlocale(LC_ALL_MASK, NULL, NULL);
|
||||
uselocale(RPC_Thread_Locale);
|
||||
#endif
|
||||
#endif
|
||||
#endif // ifndef __WXMSW__
|
||||
#endif // ifndef NO_PER_THREAD_LOCALE
|
||||
|
||||
m_pRPC_Thread_Mutex->Lock();
|
||||
|
||||
while(true) {
|
||||
// Wait for main thread to wake us
|
||||
|
@ -158,9 +160,14 @@ void *RPCThread::Entry() {
|
|||
wxASSERT(condErr == wxCOND_NO_ERROR);
|
||||
|
||||
if (m_pDoc->m_bShutDownRPCThread) {
|
||||
#ifdef RPC_Thread_Locale
|
||||
#if !defined(NO_PER_THREAD_LOCALE) && !defined(__WXMSW__)
|
||||
#if defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4)
|
||||
if (uselocale) // uselocale() is not available in Mac OS 10.3.9
|
||||
#endif
|
||||
{
|
||||
uselocale(LC_GLOBAL_LOCALE);
|
||||
freelocale(RPC_Thread_Locale);
|
||||
}
|
||||
#endif
|
||||
m_pRPC_Thread_Mutex->Unlock(); // Just for safety - not really needed
|
||||
// Tell CMainDocument that thread has gracefully ended
|
||||
|
@ -477,21 +484,21 @@ int CMainDocument::RequestRPC(ASYNC_RPC_REQUEST& request, bool hasPriority) {
|
|||
|
||||
// Start this RPC if no other RPC is already in progress.
|
||||
if (RPC_requests.size() == 1) {
|
||||
// Wait for thread to unlock mutex with m_pRPC_Thread_Condition->Wait()
|
||||
mutexErr = m_pRPC_Thread_Mutex->Lock(); // Blocks until thread unlocks the mutex
|
||||
wxASSERT(mutexErr == wxMUTEX_NO_ERROR);
|
||||
|
||||
// Make sure activation is an atomic operation
|
||||
request.isActive = false;
|
||||
current_rpc_request = request;
|
||||
current_rpc_request.isActive = true;
|
||||
|
||||
// Wait for thread to unlock mutex with m_pRPC_Thread_Condition->Wait()
|
||||
mutexErr = m_pRPC_Thread_Mutex->Lock(); // Blocks until thread unlocks the mutex
|
||||
wxASSERT(mutexErr == wxMUTEX_NO_ERROR);
|
||||
m_pRPC_Thread_Condition->Signal(); // Unblock the thread
|
||||
|
||||
// m_pRPC_Thread_Condition->Wait() will Lock() the mutex upon receiving Signal(),
|
||||
// causing it to block again if we still have our lock on the mutex.
|
||||
mutexErr = m_pRPC_Thread_Mutex->Unlock();
|
||||
wxASSERT(mutexErr == wxMUTEX_NO_ERROR);
|
||||
|
||||
m_pRPC_Thread_Condition->Signal(); // Unblock the thread
|
||||
}
|
||||
|
||||
// If this is a user-initiated event wait for completion but show
|
||||
|
@ -646,12 +653,12 @@ void CMainDocument::KillRPCThread() {
|
|||
mutexErr = m_pRPC_Thread_Mutex->Lock(); // Blocks until thread unlocks the mutex
|
||||
wxASSERT(mutexErr == wxMUTEX_NO_ERROR);
|
||||
|
||||
mutexErr = m_pRPC_Thread_Mutex->Unlock(); // Release the mutex so thread can lock it
|
||||
wxASSERT(mutexErr == wxMUTEX_NO_ERROR);
|
||||
|
||||
m_bShutDownRPCThread = true;
|
||||
m_pRPC_Thread_Condition->Signal(); // Unblock the thread
|
||||
|
||||
mutexErr = m_pRPC_Thread_Mutex->Unlock(); // Release the mutex so thread can lock it
|
||||
wxASSERT(mutexErr == wxMUTEX_NO_ERROR);
|
||||
|
||||
RPC_requests.clear();
|
||||
current_rpc_request.clear();
|
||||
|
||||
|
@ -905,21 +912,21 @@ void CMainDocument::HandleCompletedRPC() {
|
|||
// We can't start this until finished processing the previous RPC's
|
||||
// event because the two requests may write into the same buffer.
|
||||
if (RPC_requests.size() > 0) {
|
||||
// Wait for thread to unlock mutex with m_pRPC_Thread_Condition->Wait()
|
||||
mutexErr = m_pRPC_Thread_Mutex->Lock(); // Blocks until thread unlocks the mutex
|
||||
wxASSERT(mutexErr == wxMUTEX_NO_ERROR);
|
||||
|
||||
// Make sure activation is an atomic operation
|
||||
RPC_requests[0].isActive = false;
|
||||
current_rpc_request = RPC_requests[0];
|
||||
current_rpc_request.isActive = true;
|
||||
|
||||
// Wait for thread to unlock mutex with m_pRPC_Thread_Condition->Wait()
|
||||
mutexErr = m_pRPC_Thread_Mutex->Lock(); // Blocks until thread unlocks the mutex
|
||||
wxASSERT(mutexErr == wxMUTEX_NO_ERROR);
|
||||
m_pRPC_Thread_Condition->Signal(); // Unblock the thread
|
||||
|
||||
// m_pRPC_Thread_Condition->Wait() will Lock() the mutex upon receiving Signal(),
|
||||
// causing it to block again if we still have our lock on the mutex.
|
||||
mutexErr = m_pRPC_Thread_Mutex->Unlock();
|
||||
wxASSERT(mutexErr == wxMUTEX_NO_ERROR);
|
||||
|
||||
m_pRPC_Thread_Condition->Signal(); // Unblock the thread
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -484,6 +484,15 @@ bool detect_cookie_mozilla_v2(
|
|||
}
|
||||
|
||||
|
||||
#if defined(__APPLE__)
|
||||
// sqlite3 is not av ailable on Mac OS 10.3.9
|
||||
extern int sqlite3_open(const char *filename, sqlite3 **ppDb) __attribute__((weak_import));
|
||||
extern int sqlite3_close(sqlite3 *) __attribute__((weak_import));
|
||||
extern int sqlite3_exec(sqlite3*, const char *sql, sqlite3_callback, void *, char **errmsg) __attribute__((weak_import));
|
||||
extern void sqlite3_free(char *z) __attribute__((weak_import));
|
||||
#endif
|
||||
|
||||
|
||||
bool detect_cookie_mozilla_v3(
|
||||
std::string profile_root, std::string& project_url, std::string& name, std::string& value
|
||||
) {
|
||||
|
@ -495,6 +504,11 @@ bool detect_cookie_mozilla_v3(
|
|||
int rc;
|
||||
MOZILLA_COOKIE_SQL cookie;
|
||||
|
||||
#if defined(__APPLE__)
|
||||
// sqlite3 is not av ailable on Mac OS 10.3.9
|
||||
if (sqlite3_open == NULL) return false;
|
||||
#endif
|
||||
|
||||
// determine the project hostname using the project url
|
||||
parse_hostname(project_url, hostname);
|
||||
|
||||
|
|
Loading…
Reference in New Issue