@@ -50,8 +50,7 @@ const unsigned WORKER_IDLE_TIMEOUT = 60; // 1 minute
5050// / class WorkerStableAttachment
5151
5252WorkerStableAttachment::WorkerStableAttachment (FbStatusVector* status, Jrd::Attachment* attachment) :
53- SysStableAttachment (attachment),
54- m_provider (attachment->getProvider ())
53+ SysStableAttachment (attachment)
5554{
5655 UserId user;
5756 user.setUserName (" <Worker>" );
@@ -70,7 +69,6 @@ WorkerStableAttachment::WorkerStableAttachment(FbStatusVector* status, Jrd::Atta
7069 Monitoring::publishAttachment (tdbb);
7170
7271 initDone ();
73- m_provider->addRef ();
7472}
7573
7674WorkerStableAttachment::~WorkerStableAttachment ()
@@ -459,6 +457,7 @@ StableAttachmentPart* WorkerAttachment::doAttach(FbStatusVector* status, Databas
459457 {
460458 sAtt ->addRef (); // !!
461459 sAtt ->getHandle ()->setIdleTimeout (WORKER_IDLE_TIMEOUT);
460+ jInstance->addRef ();
462461 }
463462
464463 return sAtt ;
@@ -468,6 +467,15 @@ void WorkerAttachment::doDetach(FbStatusVector* status, StableAttachmentPart* sA
468467{
469468 status->init ();
470469
470+ AutoPlugin<JProvider> provider;
471+ {
472+ AttSyncLockGuard guard (*sAtt ->getSync (), FB_FUNCTION);
473+
474+ Attachment* attachment = sAtt ->getHandle ();
475+ if (attachment)
476+ provider.reset (attachment->getProvider ());
477+ }
478+
471479 // if (att->att_flags & ATT_system)
472480 if (Config::getServerMode () == MODE_SUPER)
473481 {
0 commit comments