[Ace-users] server gracefully shutdown using TP_Reactor

Odi odi.fes at gmail.com
Thu Jan 24 02:10:01 CST 2008


Hi
I'm writing a gateway application using TP_Reactor, and I encounter a
problem during shutdown.
When the reactor calls end_reactor_event_loop (); it causes  a calling
to handle_close() of all svc_handlers.
the problem is, that if a handler (lets call it H1) was running at
that same moment on some other handler (like handle_input()) its
handle_close() will be called only AFTER it returns from the current
handler.
but, at the same time H2 enter its handle_close() and deletes itself.
The problem is, that handler H1 has a pointer to H2 and it tries to
use it after H2 was deleted.

I tried to find out a resolution for this, and i thought that in this
case i need to be sure that all handlers are not in the middle of
running on other handle_*. i tried to use reactor->suspend() but still
the H1 handler will get to suspend list AFTER it returns from it
current handle_*.
So, i thought, maybe i can do something else, like cause the reactor
to call to ALL the handlers registered to it to handle_exception (as
far i as understand, handle
_exception will be called in concurency to handle_input), and do
something that will cause handle_input() to wxit right away (like
setting a flag, close its socket, deactivate its queue)

So my questions are:
1) Does this approach right? Does there any other way?
2) i didnt find a way to cause the reactor to send event too all the
handlers it contains (i dont have pointers to all handlers)

I really appritiate if you could help me.
Thanks!


More information about the Ace-users mailing list