Skip to content

Commit

Permalink
fix communicator terminate maybe cause deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanshudong committed Nov 21, 2024
1 parent 133f10c commit 691ba9c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 34 deletions.
44 changes: 22 additions & 22 deletions servant/libservant/Communicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
namespace tars
{

//////////////////////////////////////////////////////////////////////////////////////////////



//////////////////////////////////////////////////////////////////////////////////////////////

Communicator::Communicator()
Expand Down Expand Up @@ -72,7 +68,6 @@ Communicator::Communicator(TC_Config& conf, const string& domain/* = CONFIG_ROOT

Communicator::~Communicator()
{
// LOG_CONSOLE_DEBUG << endl;
ServantProxyThreadData::deconstructor(this);

terminate();
Expand Down Expand Up @@ -422,23 +417,23 @@ void Communicator::initialize()
string sSetDivision = _clientConfig.SetOpen ? _clientConfig.SetDivision : "";
_statReport->setReportInfo(statPrx, propertyPrx, _clientConfig.ModuleName, _clientConfig.LocalIp, sSetDivision, iReportInterval, iMaxReportSize, iReportTimeout);

#if TARS_OPENTRACKING
string collector_host = getProperty("collector_host", "");
string collector_port = getProperty("collector_port", "");
if(!collector_host.empty() && !collector_port.empty())
{
//init zipkin config
zipkin::ZipkinOtTracerOptions options;
options.service_name = ClientConfig::ModuleName;
options.service_address = {zipkin::IpVersion::v4, ClientConfig::LocalIp};

options.sample_rate = strtod(getProperty("sample_rate", "1.0").c_str(), NULL);
options.collector_host = collector_host;
options.collector_port = atoi(collector_port.c_str());
_traceManager = new TraceManager(options);
assert(_traceManager != NULL);
}
#endif
// #if TARS_OPENTRACKING
// string collector_host = getProperty("collector_host", "");
// string collector_port = getProperty("collector_port", "");
// if(!collector_host.empty() && !collector_port.empty())
// {
// //init zipkin config
// zipkin::ZipkinOtTracerOptions options;
// options.service_name = ClientConfig::ModuleName;
// options.service_address = {zipkin::IpVersion::v4, ClientConfig::LocalIp};

// options.sample_rate = strtod(getProperty("sample_rate", "1.0").c_str(), NULL);
// options.collector_host = collector_host;
// options.collector_port = atoi(collector_port.c_str());
// _traceManager = new TraceManager(options);
// assert(_traceManager != NULL);
// }
// #endif

}

Expand Down Expand Up @@ -759,8 +754,13 @@ ServantProxy * Communicator::setServantProxy(ServantProxy * proxy,const string&
proxy->setComm(this , objectName,setName);
return _servantProxyFactory->setServantProxy(proxy,objectName, setName, rootServant);
}

StatReport* Communicator::getStatReport()
{
if(_statReport)
{
return _statReport;
}
Communicator::initialize();

return _statReport;
Expand Down
6 changes: 0 additions & 6 deletions servant/libservant/CommunicatorEpoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,6 @@ void CommunicatorEpoll::notifyTerminate()
{
//通知网络线程去释放资源!
_epoller->syncCallback(std::bind(&CommunicatorEpoll::handleTerminate, this), 1000);

// if (_scheduler)
// {
// _epoller->syncCallback(std::bind(&CommunicatorEpoll::handleTerminate, this), 1000);
// LOG_CONSOLE_DEBUG << _scheduler.get() << endl;
// }
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions servant/libservant/ServantProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1455,12 +1455,6 @@ void ServantProxy::onSetInactive(const EndpointInfo &ep)
ce->notifySetInactive(this, ep);
});

// for (size_t i = 0; i < _rootPrx->_servantList.size(); i++)
// {
// ServantPrx &prx = _rootPrx->_servantList[i];
//
// prx->forEachObject([&](ObjectProxy *o) { o->onSetInactive(ep); });
// }
}

//在网络线程中回调
Expand Down

0 comments on commit 691ba9c

Please sign in to comment.