mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 23:23:02 +01:00
Fixed issues with shutdown thread, reported by Ilya Eremin privately
(cherry picked from commit dd1593b67d
)
This commit is contained in:
parent
06e9f5daae
commit
4c4d0b142b
@ -936,6 +936,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;
|
||||
};
|
||||
@ -8699,6 +8699,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);
|
||||
|
||||
@ -9550,6 +9561,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();
|
||||
@ -9600,11 +9613,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