Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with closing the Reactor causing a sleep_hook failure...

400 views
Skip to first unread message

dmangal

unread,
Nov 6, 2009, 4:02:44 PM11/6/09
to
ACE VERSION: 5.7.0

HOST MACHINE and OPERATING SYSTEM:
Intel Xeon E5530 and Red Hat Enterprise 5 Update 4

TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
Same as Host

COMPILER NAME AND VERSION (AND PATCHLEVEL):
g++ (GCC) 4.1.2 20080704

BUILD METHOD USED:
Makefile

AREA/CLASS/EXAMPLE AFFECTED:
ACE_Reactor, I think

DOES THE PROBLEM AFFECT:
COMPILATION? No
LINKING? No
EXECUTION? Yes

SYNOPSIS:
Calling close() function on the ACE_Reactor singleton causes
sleep_hook failure

DESCRIPTION:
I've created a networking application with 2 threads, a controller
thread & event_loop thread, and the ACE_Reactor singleton. Once the
controller thread decides to end the application, I choose to shut
everything down through these sequence of events (still in the
controller thread):
1 - if (ACE_Reactor::instance()->close() < 0) ...
2 - if (ACE_Reactor::instance()->end_reactor_event_loop() < 0) ...
3 - if (ACE_Thread_Manager::instance()->wait() < 0) ...

I expect the call to ACE_Reactor::instance()->close() to deallocate
all registered Event_Handlers & the call to end_reactor_event_loop()
to notify the currently running ACE_Reactor to shut down. However, I
keep getting the statement "sleep_hook failed: Resource temporarily
unavailable". What exactly is causing this? Is there something about
the close() function I am incorrectly assuming?
Also note that there are usually two instantiated Event_Handlers (one
using a SOCK_Acceptor & one using a SOCK_Stream). Upon calling
ACE_Reactor::instance()->close(), the object instantiations for these
Event_Handlers seem to successfully call their appropriate destructors
where I call both handles' close() function for shutting down their
sockets. So I guess this means that I at least know the instantiated
objects are successfully being deallocated by the ACE_Reactor. Not
sure why the ACE_Select_Reactor_Token is not able to return from
sleep_hook() successfully. Please also note that this exact source
works with no errors on Windows Xp (probably because the ACE_Reactor
implementation is not using ACE_Select_Reactor_T and my problem may be
specific to this *nix specific implementation). See below for my
workaround for more info...


SAMPLE FIX/WORKAROUND:
I am able to work around this by keeping track of the registered
Event_Handlers and simply calling the ACE_Reactor::remove_handler()
function for each handler. I still prefer calling
ACE_Reactor::instance()->close() as this seems to be a very simple &
presumably 'safe' way of shutting down all handlers currently
registered with the Reactor.


How do I properly get past this sleep_hook failure? Please help.

DM

0 new messages