From 5c6e3df46e6f6a357d83ac817c73780ea5e64957 Mon Sep 17 00:00:00 2001 From: rpj Date: Tue, 24 Jun 2003 13:59:27 +0000 Subject: pthread_spin_destroy was not freeing the spinlock struct. --- pthread_spin_destroy.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'pthread_spin_destroy.c') 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; } -- cgit v1.2.3