8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 09:23:03 +01:00

Fixed unregistred bug (rc3 vs rc2 regression) - races when closing touchThread

This commit is contained in:
alexpeshkoff 2010-07-14 10:27:54 +00:00
parent 16f7504427
commit 7067fb4862
2 changed files with 8 additions and 3 deletions

View File

@ -131,7 +131,7 @@ ConfigStorage::ConfigStorage() :
if (gds__thread_start(touchThread, (void*) this, THREAD_medium, 0, NULL))
gds__log("Trace facility: can't start touch thread");
else
m_touchStartSem.enter();
m_touchStartStop.tryEnter(3);
}
}
@ -139,6 +139,7 @@ ConfigStorage::~ConfigStorage()
{
// signal touchThread to finish
m_touchSemaphore->Semaphore::release();
m_touchStartStop.tryEnter(3);
::close(m_cfg_file);
m_cfg_file = -1;
@ -317,6 +318,10 @@ THREAD_ENTRY_DECLARE ConfigStorage::touchThread(THREAD_ENTRY_PARAM arg)
{
ConfigStorage* storage = (ConfigStorage*) arg;
storage->touchThreadFunc();
// release start/stop semaphore only here to avoid problems
// with dtors of local varoables in touchThreadFunc()
storage->m_touchStartStop.release();
return 0;
}
@ -326,7 +331,7 @@ void ConfigStorage::touchThreadFunc()
AnyRef<Semaphore>* semaphore = m_touchSemaphore;
Reference semRef(*semaphore);
m_touchStartSem.release();
m_touchStartStop.release();
int delay = TOUCH_INTERVAL / 2;
while (!semaphore->tryEnter(delay))

View File

@ -127,7 +127,7 @@ private:
struct mtx* m_mutex;
int m_cfg_file;
bool m_dirty;
Firebird::Semaphore m_touchStartSem;
Firebird::Semaphore m_touchStartStop;
Firebird::AnyRef<Firebird::Semaphore>* m_touchSemaphore;
Firebird::Reference m_touchSemRef;
};