Panic if lock managed by `locking_function` is doubly unlocked

Trying to unlock an unlocked lock is always an error and should
be treated as such.

This is related to #597.
This commit is contained in:
Peter Gerber 2017-03-16 21:36:43 +00:00
parent bf63f35dfb
commit f82f650953
2 changed files with 2 additions and 2 deletions

View File

@ -576,7 +576,7 @@ unsafe extern fn locking_function(mode: c_int, n: c_int, _file: *const c_char,
if mode & ::CRYPTO_LOCK != 0 { if mode & ::CRYPTO_LOCK != 0 {
(*GUARDS)[n as usize] = Some(mutex.lock().unwrap()); (*GUARDS)[n as usize] = Some(mutex.lock().unwrap());
} else { } else {
&(*GUARDS)[n as usize].take(); &(*GUARDS)[n as usize].take().expect("lock already unlocked");
} }
} }

View File

@ -719,7 +719,7 @@ unsafe extern fn locking_function(mode: c_int, n: c_int, _file: *const c_char,
if mode & ::CRYPTO_LOCK != 0 { if mode & ::CRYPTO_LOCK != 0 {
(*GUARDS)[n as usize] = Some(mutex.lock().unwrap()); (*GUARDS)[n as usize] = Some(mutex.lock().unwrap());
} else { } else {
&(*GUARDS)[n as usize].take(); &(*GUARDS)[n as usize].take().expect("lock already unlocked");
} }
} }