2002-09-27 Robert Collins <rbtcollins@hotmail.com>

* thread.cc (pthread_key::run_destructor): Run_destructor is not
       const as it needs to set the key value.
       * thread.h (pthread_key::run_destructor): Ditto.

2002-09-27  Robert Collins <rbtcollins@hotmail.com>

       * thread.cc (pthread_key::run_destructor): Follow opengroup algorithm.
       I.e. only run the destructor NON-NULL key values, and reset the key
       to NULL before running the destructor. Reported by Thomas Pfaff.
This commit is contained in:
Robert Collins 2002-09-27 15:08:50 +00:00
parent 39bd4d5016
commit da6a08decb
3 changed files with 23 additions and 4 deletions

View File

@ -1,3 +1,15 @@
2002-09-27 Robert Collins <rbtcollins@hotmail.com>
* thread.cc (pthread_key::run_destructor): Run_destructor is not
const as it needs to set the key value.
* thread.h (pthread_key::run_destructor): Ditto.
2002-09-27 Robert Collins <rbtcollins@hotmail.com>
* thread.cc (pthread_key::run_destructor): Follow opengroup algorithm.
I.e. only run the destructor NON-NULL key values, and reset the key
to NULL before running the destructor. Reported by Thomas Pfaff.
2002-09-25 Christopher Faylor <cgf@redhat.com> 2002-09-25 Christopher Faylor <cgf@redhat.com>
* cygrun.c (main): Fix setting of CYGWIN environment variable. * cygrun.c (main): Fix setting of CYGWIN environment variable.

View File

@ -1035,10 +1035,17 @@ pthread_key::recreateKeyFromBuffer ()
} }
void void
pthread_key::run_destructor () const pthread_key::run_destructor ()
{ {
if (destructor) if (destructor)
destructor (get ()); {
void *oldValue = get();
if (oldValue)
{
set (NULL);
destructor (oldValue);
}
}
} }
/*pshared mutexs: /*pshared mutexs:

View File

@ -212,7 +212,7 @@ private:
void saveKeyToBuffer (); void saveKeyToBuffer ();
void recreateKeyFromBuffer (); void recreateKeyFromBuffer ();
void (*destructor) (void *); void (*destructor) (void *);
void run_destructor () const; void run_destructor ();
void *fork_buf; void *fork_buf;
}; };