diff options
author | rpj <rpj> | 2003-06-24 13:59:27 +0000 |
---|---|---|
committer | rpj <rpj> | 2003-06-24 13:59:27 +0000 |
commit | 5c6e3df46e6f6a357d83ac817c73780ea5e64957 (patch) | |
tree | a962a61b7bd50991795bf3cd2efe2d2007179aa6 | |
parent | 4ab4cad3a48f0aa8a3abb2b23985f542f8d9e264 (diff) |
pthread_spin_destroy was not freeing the spinlock struct.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | pthread_spin_destroy.c | 11 |
2 files changed, 16 insertions, 0 deletions
@@ -1,3 +1,8 @@ +2003-06-24 Piet van Bruggen <pietvb@newbridges.nl> + + * pthread_spin_destroy.c (pthread_spin_destroy): Was not freeing the + spinlock struct. + 2003-06-22 Nicolas Barry <boozai@yahoo.com> * pthread_mutex_destroy.c (pthread_mutex_destroy): When called diff --git a/pthread_spin_destroy.c b/pthread_spin_destroy.c index 1f61930..dbe6713 100644 --- a/pthread_spin_destroy.c +++ b/pthread_spin_destroy.c @@ -60,6 +60,17 @@ pthread_spin_destroy(pthread_spinlock_t *lock) (PTW32_INTERLOCKED_LONG) PTW32_OBJECT_INVALID, (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED)) { + /* + * The spinlock isn't held by another thread so other threads that have + * just entered another spin_* routine will get PTW32_OBJECT_INVALID + * and so return EINVAL. This will not be so if the memory freed below is + * re-allocated and initialised before that happens. + * + * We are relying on the application to be responsible for ensuring that + * all other threads have finished with the spinlock before destroying it. + */ + *lock = NULL; + (void) free(s); return 0; } |