aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Collins <rbtcollins@hotmail.com>2002-09-27 15:08:50 +0000
committerRobert Collins <rbtcollins@hotmail.com>2002-09-27 15:08:50 +0000
commitda6a08decb95746b85f4562c2d3ac921eed9d91b (patch)
tree744515c9050c47ab9335635f2ec856dd2014f405
parent39bd4d5016ebad6803e2865b5494ffd5a495b4f1 (diff)
downloadnewlib-da6a08decb95746b85f4562c2d3ac921eed9d91b.zip
newlib-da6a08decb95746b85f4562c2d3ac921eed9d91b.tar.gz
newlib-da6a08decb95746b85f4562c2d3ac921eed9d91b.tar.bz2
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.
-rw-r--r--winsup/cygwin/ChangeLog12
-rw-r--r--winsup/cygwin/thread.cc13
-rw-r--r--winsup/cygwin/thread.h2
3 files changed, 23 insertions, 4 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index e3d8786..591dcfc 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -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>
* cygrun.c (main): Fix setting of CYGWIN environment variable.
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 3ee11f1..6b05cff 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -1035,10 +1035,17 @@ pthread_key::recreateKeyFromBuffer ()
}
void
-pthread_key::run_destructor () const
+pthread_key::run_destructor ()
{
- if (destructor)
- destructor (get ());
+ if (destructor)
+ {
+ void *oldValue = get();
+ if (oldValue)
+ {
+ set (NULL);
+ destructor (oldValue);
+ }
+ }
}
/*pshared mutexs:
diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h
index c364660..4be0bf1 100644
--- a/winsup/cygwin/thread.h
+++ b/winsup/cygwin/thread.h
@@ -212,7 +212,7 @@ private:
void saveKeyToBuffer ();
void recreateKeyFromBuffer ();
void (*destructor) (void *);
- void run_destructor () const;
+ void run_destructor ();
void *fork_buf;
};