[Ace-users] Regarding graceful termination of multi task ace process

sunil sunilsreenivas2001 at yahoo.com
Fri Feb 1 17:13:35 CST 2008


Hello,
 This was solved by using thread manager interface to get ACE_Thread_t
and then calling kill_thread on this. It seems like all the threads
created in all the ace tasks in application are registered with
ACE_Thread_Manager::instance().
Thanks,
Sunil
On Jan 29, 5:55 pm, sunil <sunilsreenivas2... at yahoo.com> wrote:
> ACE_VERSION: 5.4.2
> 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...
> Thank You,
> Sunil



More information about the Ace-users mailing list