From 691fb487d80e137edfd26b26722b9186c9b19d35 Mon Sep 17 00:00:00 2001 From: asfernandes Date: Wed, 6 Feb 2008 00:43:54 +0000 Subject: [PATCH] Misc --- src/common/classes/locks.cpp | 1 + src/common/classes/locks.h | 7 ++++-- src/jrd/jrd.cpp | 4 +++- src/jrd/jrd.h | 4 ++-- src/jrd/met.epp | 4 ++-- src/jrd/os/darwin/mod_loader.cpp | 37 ++++++++++++++++---------------- 6 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/common/classes/locks.cpp b/src/common/classes/locks.cpp index dafdd5a58b..436bc8da03 100644 --- a/src/common/classes/locks.cpp +++ b/src/common/classes/locks.cpp @@ -75,6 +75,7 @@ void Spinlock::init() bool Mutex::attrDone = false; pthread_mutexattr_t Mutex::attr; + void Mutex::initAttr() { // Throw exceptions on errors, but they will not be processed in first mutex constructor... diff --git a/src/common/classes/locks.h b/src/common/classes/locks.h index f20d0d3319..7aef45fc3f 100644 --- a/src/common/classes/locks.h +++ b/src/common/classes/locks.h @@ -147,6 +147,7 @@ private: static bool attrDone; static pthread_mutexattr_t attr; static void initAttr(); + void init() { if (! attrDone) initAttr(); @@ -224,7 +225,7 @@ public: try { lock->leave(); } - catch(const Exception&) + catch (const Exception&) { onDtorException(); } @@ -245,10 +246,12 @@ public: private: // Forbid copy constructor MutexLockGuard(const MutexLockGuard& source); - Mutex *lock; + #ifdef DEV_BUILD static void halt(); #endif + + Mutex* lock; }; } //namespace Firebird diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index 96f3eefd75..ac00425448 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -144,10 +144,12 @@ namespace { Database* databases = NULL; Firebird::GlobalPtr databases_rec_mutex; + inline void dbMutexLock() { databases_rec_mutex->enter(); } + inline void dbMutexUnlock() { databases_rec_mutex->leave(); @@ -184,7 +186,7 @@ namespace try { dbMutexUnlock(); } - catch(const Firebird::Exception&) + catch (const Firebird::Exception&) { Firebird::MutexLockGuard::onDtorException(); } diff --git a/src/jrd/jrd.h b/src/jrd/jrd.h index e4a5ce31fd..c244b9d389 100644 --- a/src/jrd/jrd.h +++ b/src/jrd/jrd.h @@ -268,7 +268,7 @@ public: { dbb->dbb_sync.unlock(); } - catch(const Firebird::Exception&) + catch (const Firebird::Exception&) { Firebird::MutexLockGuard::onDtorException(); } @@ -326,7 +326,7 @@ public: try { mutex->leave(); } - catch(const Firebird::Exception&) + catch (const Firebird::Exception&) { Firebird::MutexLockGuard::onDtorException(); } diff --git a/src/jrd/met.epp b/src/jrd/met.epp index ebf7fa4861..c48301cc30 100644 --- a/src/jrd/met.epp +++ b/src/jrd/met.epp @@ -3705,8 +3705,7 @@ void MET_scan_relation( thread_db* tdbb, jrd_rel* relation) Database::CheckoutLockGuard guard(dbb, dbb->dbb_sp_rec_mutex); - if (relation->rel_flags & REL_scanned - || relation->rel_flags & REL_deleted) + if (relation->rel_flags & REL_scanned || relation->rel_flags & REL_deleted) { return; } @@ -3715,6 +3714,7 @@ void MET_scan_relation( thread_db* tdbb, jrd_rel* relation) dependencies = (relation->rel_flags & REL_get_dependencies) ? true : false; sys_triggers = (relation->rel_flags & REL_sys_triggers) ? true : false; relation->rel_flags &= ~(REL_get_dependencies | REL_sys_triggers); + for (USHORT itr = 0; itr < TRIGGER_MAX; ++itr) { triggers[itr] = NULL; } diff --git a/src/jrd/os/darwin/mod_loader.cpp b/src/jrd/os/darwin/mod_loader.cpp index 780c67e1cd..480ebbf004 100644 --- a/src/jrd/os/darwin/mod_loader.cpp +++ b/src/jrd/os/darwin/mod_loader.cpp @@ -36,7 +36,7 @@ #include -void inline DebPrint(const char* s) +static void inline debugPrint(const char* s) { //printf("%s\n", s); } @@ -48,11 +48,11 @@ class DarwinModule : public ModuleLoader::Module public: DarwinModule(NSModule ns, void* dl) : nsModule(ns), dlModule(dl) { } ~DarwinModule(); - void *findSymbol(const Firebird::string&); + void* findSymbol(const Firebird::string&); private: NSModule nsModule; - void *dlModule; // non-NULL means this is dynamic library + void* dlModule; // non-NULL means this is dynamic library }; bool ModuleLoader::isLoadableModule(const Firebird::PathName& module) @@ -87,7 +87,7 @@ ModuleLoader::Module* ModuleLoader::loadModule(const Firebird::PathName& modPath case NSObjectFileImageSuccess: break; case NSObjectFileImageFailure: - DebPrint("object file setup failure"); + debugPrint("object file setup failure"); return 0; case NSObjectFileImageInappropriateFile: // try to load as dynamic library @@ -98,30 +98,30 @@ ModuleLoader::Module* ModuleLoader::loadModule(const Firebird::PathName& modPath } else { - DebPrint("not a Mach-O MH_BUNDLE file type or dynamic library"); + debugPrint("not a Mach-O MH_BUNDLE file type or dynamic library"); return 0; } case NSObjectFileImageArch: - DebPrint("no object for this architecture"); + debugPrint("no object for this architecture"); return 0; case NSObjectFileImageFormat: - DebPrint("bad object file format"); + debugPrint("bad object file format"); return 0; case NSObjectFileImageAccess: - DebPrint("can't read object file"); + debugPrint("can't read object file"); return 0; default: - DebPrint("unknown error from NSCreateObjectFileImageFromFile()"); + debugPrint("unknown error from NSCreateObjectFileImageFromFile()"); return 0; } /* link the image */ - NSModule mod_handle = - NSLinkModule(image, modPath.c_str(), NSLINKMODULE_OPTION_PRIVATE); + NSModule mod_handle = NSLinkModule(image, modPath.c_str(), NSLINKMODULE_OPTION_PRIVATE); NSDestroyObjectFileImage(image); + if (mod_handle == NULL) { - DebPrint("NSLinkModule() failed for dlopen()"); + debugPrint("NSLinkModule() failed for dlopen()"); // We should really throw an error here. return 0; } @@ -134,7 +134,7 @@ ModuleLoader::Module* ModuleLoader::loadModule(const Firebird::PathName& modPath init(); } - return FB_NEW(*getDefaultMemoryPool()) DarwinModule(mod_handle, 0); + return FB_NEW(*getDefaultMemoryPool()) DarwinModule(mod_handle, NULL); } DarwinModule::~DarwinModule() @@ -149,19 +149,19 @@ DarwinModule::~DarwinModule() NSSymbol symbol = NSLookupSymbolInModule(nsModule, "__fini"); if (symbol != NULL) { - void (*fini)(void); - fini = (void (*)(void)) NSAddressOfSymbol(symbol); + void (*fini)(); + fini = (void (*)()) NSAddressOfSymbol(symbol); fini(); } - NSUnLinkModule (nsModule, 0); + NSUnLinkModule(nsModule, 0); } } -void *DarwinModule::findSymbol(const Firebird::string& symName) +void* DarwinModule::findSymbol(const Firebird::string& symName) { if (dlModule) { - void *result = dlsym(dlModule, symName.c_str()); + void* result = dlsym(dlModule, symName.c_str()); if (result == NULL) { Firebird::string newSym = '_' + symName; @@ -180,6 +180,7 @@ void *DarwinModule::findSymbol(const Firebird::string& symName) return NULL; } } + return NSAddressOfSymbol(symbol); }