From 6534883d948e4297f82612b717901da205ff7ed5 Mon Sep 17 00:00:00 2001 From: asfernandes Date: Fri, 18 Mar 2011 02:00:11 +0000 Subject: [PATCH] Misc --- src/common/os/win32/os_utils.cpp | 12 ++++++------ src/gpre/boot/gpre_meta_boot.cpp | 4 ++-- src/jrd/idx.cpp | 2 +- src/yvalve/MasterImplementation.cpp | 9 ++++++--- src/yvalve/PluginManager.cpp | 2 ++ src/yvalve/why.cpp | 25 ++++++++++++++++--------- 6 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/common/os/win32/os_utils.cpp b/src/common/os/win32/os_utils.cpp index 291565f9fc..5df398e15b 100644 --- a/src/common/os/win32/os_utils.cpp +++ b/src/common/os/win32/os_utils.cpp @@ -247,12 +247,12 @@ bool touchFile(const char* pathname) FILETIME ft; SYSTEMTIME st; - HANDLE hFile = CreateFile(pathname, - GENERIC_READ | FILE_WRITE_ATTRIBUTES, - FILE_SHARE_READ | FILE_SHARE_WRITE, - ISC_get_security_desc(), - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, + HANDLE hFile = CreateFile(pathname, + GENERIC_READ | FILE_WRITE_ATTRIBUTES, + FILE_SHARE_READ | FILE_SHARE_WRITE, + ISC_get_security_desc(), + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, 0); if (hFile == INVALID_HANDLE_VALUE) return false; diff --git a/src/gpre/boot/gpre_meta_boot.cpp b/src/gpre/boot/gpre_meta_boot.cpp index e5cc85d218..671fd8a8d8 100644 --- a/src/gpre/boot/gpre_meta_boot.cpp +++ b/src/gpre/boot/gpre_meta_boot.cpp @@ -703,8 +703,8 @@ public: return NULL; } - virtual int FB_CARG upgradeInterface(Interface* toUpgrade, int desiredVersion, - void* missingFunctionClass) + virtual int FB_CARG upgradeInterface(Interface* /*toUpgrade*/, int /*desiredVersion*/, + void* /*missingFunctionClass*/) { fb_assert(false); return 0; diff --git a/src/jrd/idx.cpp b/src/jrd/idx.cpp index d2acbf7fe2..296a7dca69 100644 --- a/src/jrd/idx.cpp +++ b/src/jrd/idx.cpp @@ -1044,7 +1044,7 @@ static idx_e check_duplicates(thread_db* tdbb, tdbb->tdbb_status_vector[1] == isc_lock_timeout); // the above errors are not thrown but returned silently - if (lock_error) + if (lock_error) { fb_utils::init_status(tdbb->tdbb_status_vector); } diff --git a/src/yvalve/MasterImplementation.cpp b/src/yvalve/MasterImplementation.cpp index d587301868..15d3525239 100644 --- a/src/yvalve/MasterImplementation.cpp +++ b/src/yvalve/MasterImplementation.cpp @@ -372,7 +372,7 @@ struct TimerEntry Thread::start(timeThread, 0, 0, &timerThreadHandle); } - static void cleanup(void); + static void cleanup(); }; typedef SortedArray, TimerDelay, TimerEntry> TimerQueue; @@ -380,7 +380,7 @@ GlobalPtr timerQueue; InitMutex timerHolder; -void TimerEntry::cleanup(void) +void TimerEntry::cleanup() { MutexLockGuard guard(timerAccess); @@ -431,16 +431,19 @@ THREAD_ENTRY_DECLARE TimerEntry::timeThread(THREAD_ENTRY_PARAM) while (!stopThread) { TimerDelay microSeconds = 0; + { MutexLockGuard guard(timerAccess); const TimerDelay cur = curTime(); + while (timerQueue->getCount() > 0) { TimerEntry e(timerQueue->operator[](0)); + if (e.fireTime <= cur) { - timerQueue->remove((size_t)0); + timerQueue->remove((size_t) 0); e.timer->handler(); e.timer->release(); } diff --git a/src/yvalve/PluginManager.cpp b/src/yvalve/PluginManager.cpp index 5b03cb4c91..78a038fd06 100644 --- a/src/yvalve/PluginManager.cpp +++ b/src/yvalve/PluginManager.cpp @@ -349,6 +349,7 @@ namespace : counter(0), waitsOn(NULL) { } }; + struct CountByTypeArray { CountByTypeArray(MemoryPool&) @@ -892,6 +893,7 @@ void PluginManager::waitForType(unsigned int typeThatMustGoAway) Semaphore sem; Semaphore* semPtr = NULL; + { // guard scope MutexLockGuard g(plugins->mutex); diff --git a/src/yvalve/why.cpp b/src/yvalve/why.cpp index e11b524634..eff2e72474 100644 --- a/src/yvalve/why.cpp +++ b/src/yvalve/why.cpp @@ -4181,7 +4181,7 @@ ISC_STATUS API_ROUTINE isc_reconnect_transaction(ISC_STATUS* user_status, * **************************************/ StatusVector status(user_status); - ITransaction* tra = 0; + ITransaction* tra = NULL; try { @@ -4387,9 +4387,9 @@ ISC_STATUS API_ROUTINE isc_rollback_transaction(ISC_STATUS* user_status, if (sub->providerInterface) { sub->providerInterface->rollback(&status); - if ((!status.isSuccess()) && - ( !is_network_error(status) || - (transaction->flags & HANDLE_TRANSACTION_limbo) ) ) + if (!status.isSuccess() && + (!is_network_error(status) || + (transaction->flags & HANDLE_TRANSACTION_limbo))) { return status[1]; } @@ -5804,15 +5804,21 @@ int API_ROUTINE fb_shutdown(unsigned int timeout, const int reason) } // Close all known interfaces from providers ... + { // guard scope WriteLockGuard sync(handleMappingLock); HandleMapping::Accessor a(&handleMapping); - if (a.getFirst()) do + + if (a.getFirst()) { - BaseHandle* handle = a.current(); - handle->releaseAll(); - } while (a.getNext()); + do + { + BaseHandle* handle = a.current(); + handle->releaseAll(); + } while (a.getNext()); + } } + // ... and wait for all providers to go away PluginManager::waitForType(PluginType::Provider); @@ -5897,10 +5903,11 @@ ISC_STATUS API_ROUTINE fb_ping(ISC_STATUS* user_status, FB_API_HANDLE* db_handle attachment->providerInterface->ping(&status); if (!status.isSuccess()) { - if (!attachment->status.getError()) + if (!attachment->status.getError()) { attachment->status.save(status); } + { MutexLockGuard guard(*attachment->getProviderInterfaceCleanupMutex()); if (attachment->providerInterface)