gpt4 book ai didi

c++ - 当 PortableServer::ServantLocator preinvoke() 返回 CORBA::OBJECT_NOT_EXIST() 时处理 SIGABRT

转载 作者:行者123 更新时间:2023-11-28 06:09:17 24 4
gpt4 key购买 nike

以下是我使用的类的摘录,它继承自 TAO 中的 PortableServer::ServantLocator 类。当调用 preinvoke() 的覆盖方法时,如果 servant 为 NULL(在此实例之前已被销毁),我将抛出 CORBA::OBJECT_NOT_EXIST() 异常,如下所示

class Locator : public PortableServer::ServantLocator {
public:
PortableServer::Servant preinvoke(
const PortableServer::ObjectId& oid,
PortableServer::POA_ptr adapter,
const char * operation,
Cookie& cookie ) throw ()
{
.
.
.// retrieve servant
.
if (servant == NULL) {
//return NULL;
throw CORBA::OBJECT_NOT_EXIST ();
}
return servant;
}
};

但这会使进程崩溃并产生以下核心转储

  [1] __exdbg_notify_of_unexpected(0xfffffc7ffad91640, 0x1, 0xfffffc7ffb849200, 0xfffffc7ffce202e0, 0x18, 0x101010101010101), at 0xfffffc7ffce07f90
[2] __Crun::ex_chk_unexpected(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xfffffc7ffce09234
[3] Locator::preinvoke(this = 0x7c77f0, oid = CLASS, adapter = 0xdcf538, operation = 0xfffffc7ffad92740 "nextData", cookie = (nil)), line 238 in "locator.cpp"
[4] TAO::Portable_Server::RequestProcessingStrategyServantLocator::locate_servant(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xfffffc7ffd7521d2
  1. 为什么 TAO 库没有捕捉到我抛出的异常?我为此做了很多谷歌搜索,但找不到任何解决方案。我引用例子here抛出这个异常.我还尝试返回 NULL,希望 TAO 中调用函数 RequestProcessingStrategyServantLocator::locate_servant() 的 NULL 指针异常检查能够处理它。即使那样,我也会得到相同的核心转储。

  2. 我的另一个问题是,如果我已经销毁了仆人并删除了它的引用,为什么 TAO 首先调用 preinvoke()。谁能给我一个很好的例子,说明如何删除 this 引用,这样 preinvoke() 就不会被调用?

编辑

我使用的是 ACE TAO 6.0.7_x86

正如@Johnny Willemsen 的回复中所建议的,我在客户端代码处捕获异常,这是调用服务器操作的地方。但它并没有在这里被捕获。代码仍然崩溃。

我的客户端代码如下所示

      try 
{
rs->getValue(tab.out());
}
catch (CORBA::OBJECT_NOT_EXIST& x)
{
cout << "OMG OMG ERROR: CORBA : " << x << endl;
}

最佳答案

您很可能没有在客户端代码中捕获异常,异常从服务器传回给您的客户端。在 TAO 发行版中,另请参阅 TAO/tests/On_Demand_Activation 以获取此功能的单元测试。

关于c++ - 当 PortableServer::ServantLocator preinvoke() 返回 CORBA::OBJECT_NOT_EXIST() 时处理 SIGABRT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31608348/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com