Index: src/vortex_thread.c =================================================================== --- src/vortex_thread.c (revision 3242) +++ src/vortex_thread.c (working copy) @@ -212,6 +212,8 @@ return true; } +#define CLOSE_WIN32_HANDLE(X) if(!X) {} else{ CloseHandle(X); (X) = NULL; } + /** * @brief Wait for the provided thread to finish, destroy its * resources and optionally release its pointer. @@ -244,7 +246,7 @@ break; } - CloseHandle (thread_def->handle); + CLOSE_WIN32_HANDLE (thread_def->handle); axl_free (thread_def->data); if (free_data) axl_free (thread_def); @@ -336,7 +338,7 @@ #if defined(AXL_OS_WIN32) /* close the mutex */ - CloseHandle (*mutex_def); + CLOSE_WIN32_HANDLE (*mutex_def); #elif defined(AXL_OS_UNIX) /* close the mutex */ if (pthread_mutex_destroy (mutex_def) != 0) { @@ -393,7 +395,7 @@ #if defined(AXL_OS_WIN32) /* unlock mutex */ - ReleaseMutex (*mutex_def); + if( *mutex_def ) ReleaseMutex (*mutex_def); #elif defined(AXL_OS_UNIX) /* unlock mutex */ if (pthread_mutex_unlock (mutex_def) != 0) { @@ -739,10 +741,10 @@ #if defined(AXL_OS_WIN32) /* close semaphore */ - CloseHandle (cond->sema_); + CLOSE_WIN32_HANDLE (cond->sema_); /* close the event */ - CloseHandle (cond->waiters_done_); + CLOSE_WIN32_HANDLE (cond->waiters_done_); /* delete critical section */ DeleteCriticalSection (&cond->waiters_count_lock_);