[Ace-users] Regarding graceful termination of multi task ace process
sunilsreenivas2001 at yahoo.com
Tue Jan 29 16:55:55 CST 2008
HOST MACHINE AND OPERATING SYSTEM: SunOS (solaris,.9 Generic_118558-18
sun4u sparc SUNW)
COMPILER NAME AND VERSION (AND PATCH LEVEL:):studio8-v10 CC
THE $ACE_ROOT/ace/config.h FILE : #include "ace/config-win32.h"
Question: I have a server made up of multiple ace tasks. When I
receive a SIGTERM to terminate the process, I want to shutdown all the
tasks gracefully. The problem is with one of the tasks, the svc()
routine for this calls some external library routine that has its own
infinite event processing while() loop (say foo()).. I can send a
certain type of message and associate a callback handler for this
external library event processing loop however it has no way to
terminate i.e. come out of foo... This makes my problem of graceful
exit harder since according to my reading and looking at older posts
two ways to gracefully exit an ACE Task are:
a)Have a separate message for shutdown and send it over so that
whenever we look at this message in ACE_Task (after returning from
getq()), we just terminate the loop and come out of svc() routine.
b)Use thread manager and let the main thread issue a cancel and then
execute join on terminating thread.
Either case would work only if foo() returns (which is not possible
without code changes to this external routine that I dont own). I was
thinking that if I was using pthreads, I could have done
pthread_exit() and that would have done the job but with ACE_Tasks I
dont see any method in interface to do this. Also ACE_Task we use is
currently configured to run one thread but even if it were configured
to run N loops, having a wrapper that calls pthread_exit() would have
done the job for me (ACE_Task could have called pthread_exit() on
these N threads its owning)... I am now out of ideas.. Any help would
be greatly appreciated...
More information about the Ace-users