[Ace-users] error occurs when app exit in ACE_Connector::cancel
hongxing777 at gmail.com
hongxing777 at gmail.com
Thu Oct 18 05:01:48 CDT 2007
ACE version 5.6.1
Host windows xp sp2
Compiler ms visual studio 2003
In my app,I calls Reconnect in ACE_Svc_Handler::handle_close. So when
the server side is not running, my app tries to connect again and
agian. The main thread is blocking in run_reactor_event_loop. After
100 times trail, end the reactor event loop from ACE_Svc_Handler.
so the app exits.
Before exit, it calls connector.cancel(&sh);
than an run time error appears and say unhandled exception in
dbgheap.c: Microsoft C++ exception: __non_rtti_object @ 0x0012ee9c。
>From the stack, I can trace into the following code in connector.cpp:
ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::cancel (SVC_HANDLER
*sh)
{
...
NBCH *nbch =
dynamic_cast<NBCH *> (handler); <-----------------------------
error here
...
}
the Reconnect function is as following:
MyConnector::Reconnect(CMyHandler *sh)
{
ACE_Time_Value to(5);
ACE_Synch_Options options(ACE_Synch_Options::USE_REACTO, to);
if(this->connect(sh_, server_addr, options) == -1 &&
ACE_OS::last_error() != EWOULDBLOCK)
return -1;
return 0;
}
handle_close is as following:
int CMyHandler::handle_close( ACE_HANDLE handle, ACE_Reactor_Mask
mask)
{
this->shutdown();
super::handle_close(handle, mask);
this->Connector_->Reconnect(this);
}
I use the dynamic allocated ACE_Svc_Handler object when calling
ACE_Connector::connect.
Is it an problem of ACE or my problem?
Where to call Reconnect to implement the nonblocking reconnect
strategy in ACE_Svc_Handler and how to exit my app gracefully?
Thanks!
More information about the Ace-users
mailing list