mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-05 04:40:31 +09:00
init: Free global init mutex in the destructor on Windows
Fixes: #57 (T238)
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 163951d869)
This commit is contained in:
committed by
Jakub Jelen
parent
58a2943d42
commit
19c43ff6b7
15
src/init.c
15
src/init.c
@@ -161,12 +161,14 @@ static int _ssh_finalize(unsigned destructor) {
|
||||
|
||||
if (_ssh_initialized > 1) {
|
||||
_ssh_initialized--;
|
||||
goto _ret;
|
||||
ssh_mutex_unlock(&ssh_init_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (_ssh_initialized == 1) {
|
||||
if (_ssh_init_ret < 0) {
|
||||
goto _ret;
|
||||
ssh_mutex_unlock(&ssh_init_mutex);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,10 +183,17 @@ static int _ssh_finalize(unsigned destructor) {
|
||||
|
||||
_ssh_initialized = 0;
|
||||
|
||||
_ret:
|
||||
if (!destructor) {
|
||||
ssh_mutex_unlock(&ssh_init_mutex);
|
||||
}
|
||||
|
||||
#if (defined(_WIN32) && !defined(HAVE_PTHREAD))
|
||||
if (ssh_init_mutex != NULL) {
|
||||
DeleteCriticalSection(ssh_init_mutex);
|
||||
SAFE_FREE(ssh_init_mutex);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user