add gwdrop
This commit is contained in:
@ -11,12 +11,19 @@ template<typename T>
|
||||
struct getarg {};
|
||||
template<> struct getarg<int> {
|
||||
static int op(const iocshArgBuf& a) { return a.ival; }
|
||||
enum { argtype = iocshArgInt };
|
||||
};
|
||||
template<> struct getarg<double> {
|
||||
static double op(const iocshArgBuf& a) { return a.dval; }
|
||||
enum { argtype = iocshArgDouble };
|
||||
};
|
||||
template<> struct getarg<char*> {
|
||||
static char* op(const iocshArgBuf& a) { return a.sval; }
|
||||
enum { argtype = iocshArgString };
|
||||
};
|
||||
template<> struct getarg<const char*> {
|
||||
static const char* op(const iocshArgBuf& a) { return a.sval; }
|
||||
enum { argtype = iocshArgString };
|
||||
};
|
||||
|
||||
|
||||
@ -64,6 +71,7 @@ void iocshRegister(const char *name, const char *arg1name)
|
||||
detail::iocshFuncInfo<1> *info = new detail::iocshFuncInfo<1>(name);
|
||||
info->argnames[0] = arg1name;
|
||||
info->args[0].name = info->argnames[0].c_str();
|
||||
info->args[0].type = (iocshArgType)detail::getarg<T>::argtype;
|
||||
iocshRegister(&info->def, &detail::call1<T, fn>);
|
||||
}
|
||||
|
||||
|
@ -255,6 +255,10 @@ void statusServer(int lvl)
|
||||
{
|
||||
try{
|
||||
pva::ServerContextImpl::shared_pointer ctx(gblctx);
|
||||
if(!ctx) {
|
||||
std::cout<<"Not running\n";
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<pva::ChannelProvider::shared_pointer>& prov(ctx->getChannelProviders());
|
||||
|
||||
@ -294,6 +298,52 @@ void statusServer(int lvl)
|
||||
std::cerr<<"Error: "<<e.what()<<"\n";
|
||||
}
|
||||
}
|
||||
|
||||
void dropChannel(const char *chan)
|
||||
{
|
||||
if(!chan) return;
|
||||
try {
|
||||
pva::ServerContextImpl::shared_pointer ctx(gblctx);
|
||||
if(!ctx) {
|
||||
std::cout<<"Not running\n";
|
||||
return;
|
||||
}
|
||||
std::cout<<"Find and force drop channel '"<<chan<<"'\n";
|
||||
|
||||
const std::vector<pva::ChannelProvider::shared_pointer>& prov(ctx->getChannelProviders());
|
||||
|
||||
for(size_t i=0; i<prov.size(); i++)
|
||||
{
|
||||
pva::ChannelProvider* p = prov[i].get();
|
||||
if(!p) continue;
|
||||
GWServerChannelProvider *scp = dynamic_cast<GWServerChannelProvider*>(p);
|
||||
if(!scp) continue;
|
||||
|
||||
ChannelCacheEntry::shared_pointer entry;
|
||||
|
||||
// find the channel, if it's there
|
||||
{
|
||||
Guard G(scp->cache.cacheLock);
|
||||
|
||||
ChannelCache::entries_t::iterator it = scp->cache.entries.find(chan);
|
||||
if(it==scp->cache.entries.end())
|
||||
continue;
|
||||
|
||||
std::cout<<"Found in provider "<<p->getProviderName()<<"\n";
|
||||
|
||||
entry = it->second;
|
||||
scp->cache.entries.erase(it); // drop out of cache
|
||||
}
|
||||
|
||||
entry->channel->destroy(); // trigger client side disconnect
|
||||
}
|
||||
|
||||
std::cout<<"Done\n";
|
||||
}catch(std::exception& e){
|
||||
std::cerr<<"Error: "<<e.what()<<"\n";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
static
|
||||
@ -307,6 +357,7 @@ void registerGWServerIocsh()
|
||||
iocshRegister<&startServer>("gwstart");
|
||||
iocshRegister<&stopServer>("gwstop");
|
||||
iocshRegister<int, &statusServer>("gwstatus", "level");
|
||||
iocshRegister<const char*, &dropChannel>("gwdrop", "channel");
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user