diff options
author | Steve Nairn <steven.nairn@kewill.com> | 2015-03-03 19:40:06 +0800 |
---|---|---|
committer | Daniel Veillard <veillard@redhat.com> | 2015-03-03 19:42:01 +0800 |
commit | 620a70615e68b30db1a80a993180a41dc24f12b9 (patch) | |
tree | 77090b496f56a7c79e25268c4239e6ba31112dff | |
parent | 9b987f8c98763ee569bde90b5268b43474ca106c (diff) | |
download | libxml2-620a70615e68b30db1a80a993180a41dc24f12b9.tar.gz |
Fix the fix to Windows locking
For https://bugzilla.gnome.org/show_bug.cgi?id=737851
Unfortunately this change has introduced a problem which results in
occasional hangs on Windows when running multi-threaded on a multi-core
host.
When locking the xmlRMutex the count field is increment inside the
critical section but when unlocking the count field is decremented
outside the critical section. The increment/decrement is not atomic so
this can result in the count field being updated incorrectly.
The solution is to change xmlRMutexUnlock to decrement the count field
before leaving the critical section rather than after.
-rw-r--r-- | threads.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -415,8 +415,8 @@ xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED) pthread_mutex_unlock(&tok->lock); #elif defined HAVE_WIN32_THREADS if (tok->count > 0) { - LeaveCriticalSection(&tok->cs); tok->count--; + LeaveCriticalSection(&tok->cs); } #elif defined HAVE_BEOS_THREADS if (tok->lock->tid == find_thread(NULL)) { |