fix s_channelNameToProvider hack
Move from global to ServerContext, apply lock, and properly test if no provider has claimed, eg an attempt at unadvertised PV (still wouldn't work, but at least wouldn't crash).
This commit is contained in:
@ -115,9 +115,6 @@ private:
|
||||
class ServerSearchHandler : public AbstractServerResponseHandler
|
||||
{
|
||||
public:
|
||||
// TODO
|
||||
static std::map<std::string, std::tr1::weak_ptr<ChannelProvider> > s_channelNameToProvider;
|
||||
|
||||
static const std::string SUPPORTED_PROTOCOL;
|
||||
|
||||
ServerSearchHandler(ServerContextImpl::shared_pointer const & context);
|
||||
|
@ -137,6 +137,9 @@ public:
|
||||
*/
|
||||
bool isChannelProviderNamePreconfigured();
|
||||
|
||||
// used by ServerChannelFindRequesterImpl
|
||||
typedef std::map<std::string, std::tr1::weak_ptr<ChannelProvider> > s_channelNameToProvider_t;
|
||||
s_channelNameToProvider_t s_channelNameToProvider;
|
||||
private:
|
||||
|
||||
/**
|
||||
@ -218,7 +221,9 @@ private:
|
||||
// const after loadConfiguration()
|
||||
std::vector<ChannelProvider::shared_pointer> _channelProviders;
|
||||
|
||||
public:
|
||||
epics::pvData::Mutex _mutex;
|
||||
private:
|
||||
|
||||
epics::pvData::Event _runEvent;
|
||||
|
||||
|
@ -400,8 +400,6 @@ ServerChannelFindRequesterImpl* ServerChannelFindRequesterImpl::set(std::string
|
||||
return this;
|
||||
}
|
||||
|
||||
std::map<string, std::tr1::weak_ptr<ChannelProvider> > ServerSearchHandler::s_channelNameToProvider;
|
||||
|
||||
void ServerChannelFindRequesterImpl::channelFindResult(const Status& /*status*/, ChannelFind::shared_pointer const & channelFind, bool wasFound)
|
||||
{
|
||||
// TODO status
|
||||
@ -427,7 +425,8 @@ void ServerChannelFindRequesterImpl::channelFindResult(const Status& /*status*/,
|
||||
{
|
||||
if (wasFound && _expectedResponseCount > 1)
|
||||
{
|
||||
ServerSearchHandler::s_channelNameToProvider[_name] = channelFind->getChannelProvider();
|
||||
Lock L(_context->_mutex);
|
||||
_context->s_channelNameToProvider[_name] = channelFind->getChannelProvider();
|
||||
}
|
||||
_wasFound = wasFound;
|
||||
|
||||
@ -760,11 +759,20 @@ void ServerCreateChannelHandler::handleResponse(osiSockAddr* responseFrom,
|
||||
else
|
||||
{
|
||||
const std::vector<ChannelProvider::shared_pointer>& _providers(_context->getChannelProviders());
|
||||
ServerContextImpl::s_channelNameToProvider_t::const_iterator it;
|
||||
|
||||
if (_providers.size() == 1)
|
||||
ServerChannelRequesterImpl::create(_providers[0], transport, channelName, cid, css);
|
||||
else
|
||||
ServerChannelRequesterImpl::create(ServerSearchHandler::s_channelNameToProvider[channelName].lock(), transport, channelName, cid, css); // TODO !!!!
|
||||
else {
|
||||
ChannelProvider::shared_pointer prov;
|
||||
{
|
||||
Lock L(_context->_mutex);
|
||||
if((it = _context->s_channelNameToProvider.find(channelName)) != _context->s_channelNameToProvider.end())
|
||||
prov = it->second.lock();
|
||||
}
|
||||
if(prov)
|
||||
ServerChannelRequesterImpl::create(prov, transport, channelName, cid, css);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user