Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Source/Thunder/PluginServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,7 @@ namespace PluginHost {
, _service()
, _requestClose(false)
, _jobs()
, _serviceCleanedUp(false)
{
TRACE(Activity, (_T("Construct a link with ID: [%d] to [%s]"), Id(), remoteId.QualifiedName().c_str()));

Expand All @@ -1214,11 +1215,8 @@ namespace PluginHost {
TRACE(Activity, (_T("Destruct a link with ID [%d] to [%s]"), Id(), RemoteId().c_str()));

// If we are still atatched to a service, detach, we are out of scope...
if (_service.IsValid() == true) {
_service->Unsubscribe(*this);
CleanupService();

_service.Release();
}
if (_security != nullptr) {
_security->Release();
_security = nullptr;
Expand Down
19 changes: 15 additions & 4 deletions Source/Thunder/PluginServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "IRemoteInstantiation.h"
#include "WarningReportingCategories.h"
#include "PostMortem.h"
#include <atomic>

#ifndef HOSTING_COMPROCESS
#error "Please define the name of the COM process!!!"
Expand Down Expand Up @@ -5353,11 +5354,8 @@ namespace PluginHost {

// If we are closing (or closed) do the clean up
if (IsOpen() == false) {
if (_service.IsValid() == true) {
_service->Detach(*this);

_service.Release();
}
CleanupService();

State(CLOSED, false);

Expand Down Expand Up @@ -5427,11 +5425,24 @@ namespace PluginHost {
SetId(id);
}

void CleanupService()
{
bool expected = false;
if (_serviceCleanedUp.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
if (_service.IsValid() == true) {
_service->Unsubscribe(*this);
_service->Detach(*this);
_service.Release();
}
}
}

Server& _parent;
PluginHost::ISecurity* _security;
Core::ProxyType<Service> _service;
bool _requestClose;
Jobs _jobs;
std::atomic<bool> _serviceCleanedUp;

// Factories for creating jobs that can be placed on the PluginHost Worker pool.
static Core::ProxyPoolType<WebRequestJob> _webJobs;
Expand Down
Loading