This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: pthread_exit() and tss destructors
- From: Nick Garnett <nickg at redhat dot com>
- To: Robin Farine <robin dot farine at acn-group dot ch>
- Cc: eCos users <ecos-discuss at sources dot redhat dot com>
- Date: 27 Feb 2002 13:05:56 +0000
- Subject: Re: [ECOS] pthread_exit() and tss destructors
- References: <1014808655.12543.59.camel@halftrack>
Robin Farine <robin.farine@acn-group.ch> writes:
> Hi,
>
> Third-party code using POSIX threads and tss caused me some trouble when
> such a thread exited. It turned out that tss destructors got called
> multiple times for the same key. According to the POSIX 1003.1 standard,
> the code calling these destructors should set each value to NULL before
> calling the associated destructor.
>
It is my reading of the standard that it is the responsibility of the
destructor function itself to set the value to NULL, or some other
value. Otherwise there would be no need for {PTHREAD_DESTRUCTOR_ITERATIONS}.
There is nothing in the rationale about this either. This looks like
one of those situations where the POSIX standard is incompletely
specific. To be completely portable it looks like destructor code
cannot assume that the keys will be NULLed, and must do it itself with
pthread_setspecific().
--
Nick Garnett, eCos Kernel Architect
Red Hat, Cambridge, UK
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss