[omniORB] How to kill an omni_thread ???

Andreas.Koehler koehler@vs.dasa.de
Thu, 5 Nov 1998 14:14:36 +0100 (MET)



On 5 Nov 1998, Tristan Richardson wrote:

> "Andreas.Koehler" <koehler@vs.dasa.de> writes:
> 
> > using omniORB2 our pthread implementation should be substituted with
> > omni_threads. One of the implemented functionality creates a pthread,
> > waits for TIMEOUT seconds and will kill the pthread, if the pthread is
> > still running after TIMEOUT seconds:
> > 
> >   pthread_t thr;
> >   pthread_attr_t attr;
> >   pthread_attr_init (&attr);
> >   pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
> >   if (pthread_create (&thr, &attr, <function_ptr>, <arg_ptr>)) {
> >         perror ("thread creation failed");
> >         kill (getpid (), SIGTERM); // terminating with implemented handler
> >   }
> >   ...
> >   pthread_kill(thr, SIGINT);
> > 
> > Now we create an omni_thread with:
> > 
> >   omni_thread *thr;
> >   thr = omni_thread::create(<function_ptr>, <arg_ptr>);
> > 
> > But what's the analogon to pthread_kill? Calling the destructor is not
> > allowed!
> 
> 
> There is intentionally no "thread kill" functionality in omnithread.  For
> all but the most trivial of cases (i.e. if the thread ever locks a mutex),
> it is just about impossible to kill a thread like this without introducing
> errors into your program.  A thread should always be responsible for its own
> destruction.  If from another thread you want to tell a thread to exit then
> you do this using the normal synchronisation primitives, and the thread
> itself exits at a point where it can do so cleanly.

... very bad. As mentioned some mails bevor we have problems with the
exception handling. If server crashes, invoked proxy calls will hang
neverending. That's why we wanted to call every proxy function within
it's own thread, that can be killed by the main thread.

May be we should solve our exception problem somehow differently!

Ciao
Andreas