mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-02-02 10:00:38 +01:00
Fixed issues with shutdown thread, reported by Ilya Eremin privately
This commit is contained in:
parent
4f596424d1
commit
dd1593b67d
@ -943,6 +943,11 @@ public:
|
||||
iter.remove();
|
||||
}
|
||||
|
||||
bool hasData() const
|
||||
{
|
||||
return m_attachments.hasData();
|
||||
}
|
||||
|
||||
private:
|
||||
AttachmentsRefHolder(const AttachmentsRefHolder&);
|
||||
|
||||
|
@ -118,13 +118,13 @@ namespace Jrd {
|
||||
while (thr.hasData())
|
||||
{
|
||||
FB_SIZE_T n = thr.getCount() - 1;
|
||||
Thrd& t = thr[n];
|
||||
Thrd t = thr[n];
|
||||
thr.remove(n);
|
||||
{
|
||||
Firebird::MutexUnlockGuard u(threadsMutex, FB_FUNCTION);
|
||||
Thread::waitForCompletion(t.hndl);
|
||||
fb_assert(t.ending);
|
||||
}
|
||||
thr.remove(n);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -482,7 +482,7 @@ namespace
|
||||
|
||||
struct AttShutParams
|
||||
{
|
||||
Semaphore thdStartedSem;
|
||||
Semaphore thdStartedSem, startCallCompleteSem;
|
||||
Thread::Handle thrHandle;
|
||||
AttachmentsRefHolder* attachments;
|
||||
};
|
||||
@ -8779,6 +8779,17 @@ namespace
|
||||
|
||||
AttShutParams* params = static_cast<AttShutParams*>(arg);
|
||||
AttachmentsRefHolder* attachments = params->attachments;
|
||||
|
||||
try
|
||||
{
|
||||
params->startCallCompleteSem.enter();
|
||||
}
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
iscLogException("attachmentShutdownThread", ex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Thread::Handle th = params->thrHandle;
|
||||
fb_assert(th);
|
||||
|
||||
@ -9592,6 +9603,8 @@ void JRD_shutdown_attachment(Attachment* attachment)
|
||||
AttShutParams params;
|
||||
params.attachments = queue;
|
||||
Thread::start(attachmentShutdownThread, ¶ms, THREAD_high, ¶ms.thrHandle);
|
||||
params.startCallCompleteSem.release();
|
||||
|
||||
queue.release();
|
||||
shutThreadCollect->houseKeeping();
|
||||
params.thdStartedSem.enter();
|
||||
@ -9642,11 +9655,13 @@ void JRD_shutdown_attachments(Database* dbb)
|
||||
}
|
||||
}
|
||||
|
||||
if (queue.hasData())
|
||||
if (queue->hasData())
|
||||
{
|
||||
AttShutParams params;
|
||||
params.attachments = queue;
|
||||
Thread::start(attachmentShutdownThread, ¶ms, THREAD_high, ¶ms.thrHandle);
|
||||
params.startCallCompleteSem.release();
|
||||
|
||||
queue.release();
|
||||
shutThreadCollect->houseKeeping();
|
||||
params.thdStartedSem.enter();
|
||||
|
Loading…
Reference in New Issue
Block a user