Jacek Caban : winhttp: Make accessing session credential handle thread safe.
Alexandre Julliard
julliard at winehq.org
Fri Oct 5 16:40:40 CDT 2018
Module: wine
Branch: master
Commit: 543bfdf1af21bac4261c227fc84efabd93726c95
URL: https://source.winehq.org/git/wine.git/?a=commit;h=543bfdf1af21bac4261c227fc84efabd93726c95
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Oct 5 14:59:18 2018 +0200
winhttp: Make accessing session credential handle thread safe.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winhttp/request.c | 24 ++++++++++++++++--------
dlls/winhttp/session.c | 2 ++
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index 960c755..d101023 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -1608,21 +1608,29 @@ static DWORD map_secure_protocols( DWORD mask )
static BOOL ensure_cred_handle( session_t *session )
{
- SCHANNEL_CRED cred;
- SECURITY_STATUS status;
+ SECURITY_STATUS status = SEC_E_OK;
if (session->cred_handle_initialized) return TRUE;
- memset( &cred, 0, sizeof(cred) );
- cred.dwVersion = SCHANNEL_CRED_VERSION;
- cred.grbitEnabledProtocols = map_secure_protocols( session->secure_protocols );
- if ((status = AcquireCredentialsHandleW( NULL, (WCHAR *)UNISP_NAME_W, SECPKG_CRED_OUTBOUND, NULL, &cred,
- NULL, NULL, &session->cred_handle, NULL )) != SEC_E_OK)
+ EnterCriticalSection( &session->cs );
+ if (!session->cred_handle_initialized)
+ {
+ SCHANNEL_CRED cred;
+ memset( &cred, 0, sizeof(cred) );
+ cred.dwVersion = SCHANNEL_CRED_VERSION;
+ cred.grbitEnabledProtocols = map_secure_protocols( session->secure_protocols );
+ status = AcquireCredentialsHandleW( NULL, (WCHAR *)UNISP_NAME_W, SECPKG_CRED_OUTBOUND, NULL,
+ &cred, NULL, NULL, &session->cred_handle, NULL );
+ if (status == SEC_E_OK)
+ session->cred_handle_initialized = TRUE;
+ }
+ LeaveCriticalSection( &session->cs );
+
+ if (status != SEC_E_OK)
{
WARN( "AcquireCredentialsHandleW failed: 0x%08x\n", status );
return FALSE;
}
- session->cred_handle_initialized = TRUE;
return TRUE;
}
diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c
index 7078e47..b9d9ab8 100644
--- a/dlls/winhttp/session.c
+++ b/dlls/winhttp/session.c
@@ -198,7 +198,9 @@ static BOOL session_set_option( object_header_t *hdr, DWORD option, LPVOID buffe
set_last_error( ERROR_INSUFFICIENT_BUFFER );
return FALSE;
}
+ EnterCriticalSection( &session->cs );
session->secure_protocols = *(DWORD *)buffer;
+ LeaveCriticalSection( &session->cs );
TRACE("0x%x\n", session->secure_protocols);
return TRUE;
}
More information about the wine-cvs
mailing list