mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 14:03:02 +01:00
Better fix for AV at exit() time, CORE-2917 :
a) WaitForSingleObject hungs when process unloads embedded library b) shmem file was changed in incompatime way so build 26000 can't work together with any previous builds c) time_t in shmem replaced by SINT64 to avoid possible issues with builds by MSVC 7.1 (where time_t is 32-bit)
This commit is contained in:
parent
47bd7b1df6
commit
0979b7c928
@ -66,13 +66,13 @@ namespace Firebird
|
||||
explicit Reference(RefCounted& refCounted) :
|
||||
r(refCounted)
|
||||
{
|
||||
r.addRef();
|
||||
r.RefCounted::addRef();
|
||||
}
|
||||
|
||||
~Reference()
|
||||
{
|
||||
try {
|
||||
r.release();
|
||||
r.RefCounted::release();
|
||||
}
|
||||
catch (const Exception&)
|
||||
{
|
||||
|
@ -79,13 +79,13 @@ void checkFileError(const char* filename, const char* operation, ISC_STATUS iscE
|
||||
#endif
|
||||
}
|
||||
|
||||
ConfigStorage::ConfigStorage()
|
||||
ConfigStorage::ConfigStorage() :
|
||||
m_base(NULL),
|
||||
m_cfg_file(-1),
|
||||
m_dirty(false),
|
||||
m_touchSemaphore(FB_NEW(*getDefaultMemoryPool()) AnyRef<Semaphore>),
|
||||
m_touchSemRef(*m_touchSemaphore)
|
||||
{
|
||||
m_base = NULL;
|
||||
m_cfg_file = -1;
|
||||
m_dirty = false;
|
||||
m_thdId = 0;
|
||||
|
||||
PathName filename;
|
||||
#ifdef WIN_NT
|
||||
DWORD sesID = 0;
|
||||
@ -120,20 +120,25 @@ ConfigStorage::ConfigStorage()
|
||||
status_exception::raise(status);
|
||||
}
|
||||
|
||||
fb_assert(m_base->version == 1);
|
||||
fb_assert(m_base->version == 1 || m_base->version == 2);
|
||||
|
||||
StorageGuard guard(this);
|
||||
checkFile();
|
||||
++m_base->cnt_uses;
|
||||
|
||||
gds__thread_start(touchThread, (void*) this, THREAD_medium, 0, &m_thdId);
|
||||
if (m_base->version == 2)
|
||||
{
|
||||
if (gds__thread_start(touchThread, (void*) this, THREAD_medium, 0, NULL))
|
||||
gds__log("Can't start touch thread");
|
||||
else
|
||||
m_touchStartSem.enter();
|
||||
}
|
||||
}
|
||||
|
||||
ConfigStorage::~ConfigStorage()
|
||||
{
|
||||
// signal touchThread to finish
|
||||
m_touchSemaphore.release();
|
||||
THD_wait_for_completion(m_thdId);
|
||||
m_touchSemaphore->Semaphore::release();
|
||||
|
||||
::close(m_cfg_file);
|
||||
m_cfg_file = -1;
|
||||
@ -181,7 +186,7 @@ void ConfigStorage::initShMem(void* arg, sh_mem* shmemData, bool initialize)
|
||||
// Initialize the shared data header
|
||||
if (initialize)
|
||||
{
|
||||
header->version = 1;
|
||||
header->version = 2;
|
||||
header->change_number = 0;
|
||||
header->session_number = 1;
|
||||
header->cnt_uses = 0;
|
||||
@ -311,8 +316,13 @@ THREAD_ENTRY_DECLARE ConfigStorage::touchThread(THREAD_ENTRY_PARAM arg)
|
||||
|
||||
void ConfigStorage::touchThreadFunc()
|
||||
{
|
||||
AnyRef<Semaphore>* semaphore = m_touchSemaphore;
|
||||
Reference semRef(*semaphore);
|
||||
|
||||
m_touchStartSem.release();
|
||||
|
||||
int delay = TOUCH_INTERVAL / 2;
|
||||
while (!m_touchSemaphore.tryEnter(delay))
|
||||
while (!semaphore->tryEnter(delay))
|
||||
{
|
||||
StorageGuard guard(this);
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "../../common/classes/array.h"
|
||||
#include "../../common/classes/fb_string.h"
|
||||
#include "../../common/classes/init.h"
|
||||
#include "../../common/classes/RefCounted.h"
|
||||
#include "../../common/classes/semaphore.h"
|
||||
#include "../../jrd/isc.h"
|
||||
#include "../../jrd/ThreadStart.h"
|
||||
@ -95,11 +96,11 @@ private:
|
||||
volatile ULONG change_number;
|
||||
volatile ULONG session_number;
|
||||
ULONG cnt_uses;
|
||||
time_t touch_time;
|
||||
char cfg_file_name[MAXPATHLEN];
|
||||
#ifndef WIN_NT
|
||||
struct mtx mutex;
|
||||
#endif
|
||||
SINT64 touch_time;
|
||||
};
|
||||
|
||||
// items in every session record at sessions file
|
||||
@ -125,8 +126,9 @@ private:
|
||||
#endif
|
||||
int m_cfg_file;
|
||||
bool m_dirty;
|
||||
Firebird::Semaphore m_touchSemaphore;
|
||||
ThreadHandle m_thdId;
|
||||
Firebird::Semaphore m_touchStartSem;
|
||||
Firebird::AnyRef<Firebird::Semaphore>* m_touchSemaphore;
|
||||
Firebird::Reference m_touchSemRef;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user