8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 15:23:02 +01:00
This commit is contained in:
asfernandes 2008-02-06 00:43:54 +00:00
parent 5df029fd63
commit 691fb487d8
6 changed files with 32 additions and 25 deletions

View File

@ -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...

View File

@ -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

View File

@ -144,10 +144,12 @@ namespace
{
Database* databases = NULL;
Firebird::GlobalPtr<Firebird::Mutex> 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();
}

View File

@ -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();
}

View File

@ -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;
}

View File

@ -36,7 +36,7 @@
#include <mach-o/dyld.h>
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);
}