"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/common/classes/init.cpp" between
Firebird-3.0.2.32703-0.tar.bz2 and Firebird-3.0.4.33054-0.tar.bz2

About: Firebird is a relational database offering many ANSI SQL standard features.

init.cpp  (Firebird-3.0.2.32703-0.tar.bz2):init.cpp  (Firebird-3.0.4.33054-0.tar.bz2)
skipping to change at line 32 skipping to change at line 32
* *
* All Rights Reserved. * All Rights Reserved.
* Contributor(s): ______________________________________. * Contributor(s): ______________________________________.
*/ */
#include "firebird.h" #include "firebird.h"
#include "init.h" #include "init.h"
#include "alloc.h" #include "alloc.h"
#include "../common/SimpleStatusVector.h" #include "../common/SimpleStatusVector.h"
#include "../common/dllinst.h" #include "../common/dllinst.h"
#include "../common/os/os_utils.h"
#ifdef HAVE_DLADDR
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <dlfcn.h>
#endif // HAVE_DLADDR
// Setting this define helps (with AV at exit time) detect globals // Setting this define helps (with AV at exit time) detect globals
// with destructors, declared not using InstanceControl. // with destructors, declared not using InstanceControl.
// The reason for AV is that process memory pool (from where globals should allo cate memory) // The reason for AV is that process memory pool (from where globals should allo cate memory)
// is destroyed in atexit(), before destructors are called. Therefore each delet e // is destroyed in atexit(), before destructors are called. Therefore each delet e
// operator in destructor will cause AV. // operator in destructor will cause AV.
#undef DEBUG_INIT #undef DEBUG_INIT
static bool dontCleanup = false; static bool dontCleanup = false;
skipping to change at line 87 skipping to change at line 95
} }
initDone = 2; initDone = 2;
#ifdef WIN_NT #ifdef WIN_NT
if (Firebird::bDllProcessExiting) if (Firebird::bDllProcessExiting)
dontCleanup = true; dontCleanup = true;
#endif #endif
if (dontCleanup) if (dontCleanup)
return; return;
#ifdef DEBUG_GDS_ALLOC
Firebird::AutoPtr<FILE> file;
{ // scope
Firebird::PathName name = "memdebug.log";
#ifdef HAVE_DLADDR
Dl_info path;
if (dladdr((void*) &allClean, &path))
{
name = path.dli_fname;
name += ".memdebug.log";
}
else
{
fprintf(stderr, "dladdr: %s\n", dlerror());
}
#elif defined(WIN_NT)
HMODULE hmod = 0;
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
| GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
(LPCTSTR) &allClean,
&hmod);
if (hmod)
{
char moduleName[MAX_PATH];
DWORD len = GetModuleFileName(hmod, moduleName, M
AX_PATH);
if (len < MAX_PATH)
{
name = moduleName;
name += ".memdebug.log";
}
}
#endif // HAVE_DLADDR
file = os_utils::fopen(name.c_str(), "w+t");
}
#endif // DEBUG_GDS_ALLOC
Firebird::InstanceControl::destructors(); Firebird::InstanceControl::destructors();
if (dontCleanup) if (dontCleanup)
return; return;
try try
{ {
Firebird::StaticMutex::release(); Firebird::StaticMutex::release();
} }
catch (...) catch (...)
{ {
cleanError(NULL); cleanError(NULL);
} }
try try
{ {
#ifdef DEBUG_GDS_ALLOC
// In Debug mode - this will report all memory leaks
if (file)
{
getDefaultMemoryPool()->print_contents(file,
Firebird::MemoryPool::PRINT_USED_ONLY | F
irebird::MemoryPool::PRINT_RECURSIVE);
file = NULL;
}
#endif
Firebird::MemoryPool::cleanup(); Firebird::MemoryPool::cleanup();
} }
catch (...) catch (...)
{ {
cleanError(NULL); cleanError(NULL);
} }
} }
#ifndef DEBUG_INIT #ifndef DEBUG_INIT
// This class with it's single instance ensures global cleanup // This class with it's single instance ensures global cleanup
skipping to change at line 175 skipping to change at line 229
{ {
// Initialize required subsystems, including static mutex // Initialize required subsystems, including static mutex
init(); init();
} }
InstanceControl::InstanceList::InstanceList(DtorPriority p) InstanceControl::InstanceList::InstanceList(DtorPriority p)
: priority(p) : priority(p)
{ {
MutexLockGuard guard(*StaticMutex::mutex, "InstanceControl::Insta nceList::InstanceList"); MutexLockGuard guard(*StaticMutex::mutex, "InstanceControl::Insta nceList::InstanceList");
next = instanceList; next = instanceList;
prev = NULL;
if (instanceList)
instanceList->prev = this;
instanceList = this; instanceList = this;
} }
InstanceControl::InstanceList::~InstanceList() InstanceControl::InstanceList::~InstanceList()
{ {
delete next; fb_assert(next == NULL);
fb_assert(prev == NULL);
}
void InstanceControl::InstanceList::remove()
{
MutexLockGuard guard(*StaticMutex::mutex, FB_FUNCTION);
unlist();
}
void InstanceControl::InstanceList::unlist()
{
if (instanceList == this)
instanceList = next;
if (next)
next->prev = this->prev;
if (prev)
prev->next = this->next;
prev = NULL;
next = NULL;
} }
void InstanceControl::destructors() void InstanceControl::destructors()
{ {
// Call fb_shutdown() if needed // Call fb_shutdown() if needed
if (gdsShutdown) if (gdsShutdown)
{ {
try try
{ {
gdsShutdown(); gdsShutdown();
skipping to change at line 246 skipping to change at line 325
else if (i->priority > currentPriority) else if (i->priority > currentPriority)
{ {
if (nextPriority == currentPriority || i- >priority < nextPriority) if (nextPriority == currentPriority || i- >priority < nextPriority)
{ {
nextPriority = i->priority; nextPriority = i->priority;
} }
} }
} }
} while (nextPriority != currentPriority); } while (nextPriority != currentPriority);
delete instanceList; while (instanceList)
instanceList = 0; {
InstanceList* item = instanceList;
item->unlist();
delete item;
}
} }
void InstanceControl::registerGdsCleanup(FPTR_VOID cleanup) void InstanceControl::registerGdsCleanup(FPTR_VOID cleanup)
{ {
fb_assert(!gdsCleanup || !cleanup || gdsCleanup == cleanup); fb_assert(!gdsCleanup || !cleanup || gdsCleanup == cleanup);
gdsCleanup = cleanup; gdsCleanup = cleanup;
} }
void InstanceControl::registerShutdown(FPTR_VOID shutdown) void InstanceControl::registerShutdown(FPTR_VOID shutdown)
{ {
 End of changes. 6 change blocks. 
3 lines changed or deleted 89 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)