Fix error

This commit is contained in:
Alexey Milovidov 2022-08-06 20:46:42 +02:00 committed by vdimir
parent f554ff9d99
commit f15623141e
No known key found for this signature in database
GPG Key ID: 6EE4CE2BEDC51862

View File

@ -104,15 +104,24 @@ public:
class ScopedAttach : private boost::noncopyable class ScopedAttach : private boost::noncopyable
{ {
private:
bool attached = false;
public: public:
explicit ScopedAttach(const ThreadGroupStatusPtr & thread_group) explicit ScopedAttach(const ThreadGroupStatusPtr & thread_group)
{ {
CurrentThread::attachTo(thread_group); if (!CurrentThread::getGroup())
{
CurrentThread::attachToIfDetached(thread_group);
attached = true;
}
} }
~ScopedAttach() ~ScopedAttach()
{ {
CurrentThread::detachQuery(); if (attached)
{
CurrentThread::detachQuery();
}
} }
}; };