From a54ea12557d02ff4fe62aba244240aad3f57e811 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 19 May 2019 17:34:34 +0000 Subject: * dso/win32/dso.c (apr_dso_load): Use SetThreadErrorMode() instead of SetErrorMode(), because SetErrorMode() is not thread-safe. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1859519 13f79535-47bb-0310-9956-ffa450edef68 --- dso/win32/dso.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dso/win32/dso.c b/dso/win32/dso.c index 3433c7e31..9681d91b5 100644 --- a/dso/win32/dso.c +++ b/dso/win32/dso.c @@ -69,7 +69,10 @@ APR_DECLARE(apr_status_t) apr_dso_load(struct apr_dso_handle_t **res_handle, } /* Prevent ugly popups from killing our app */ #ifndef _WIN32_WCE - em = SetErrorMode(SEM_FAILCRITICALERRORS); + if (!SetThreadErrorMode(SEM_FAILCRITICALERRORS, &em)) { + *res_handle = apr_pcalloc(ctx, sizeof(**res_handle)); + return ((*res_handle)->load_error = apr_get_os_error()); + } #endif os_handle = LoadLibraryExW(wpath, NULL, 0); if (!os_handle) @@ -87,7 +90,7 @@ APR_DECLARE(apr_status_t) apr_dso_load(struct apr_dso_handle_t **res_handle, #endif } #ifndef _WIN32_WCE - SetErrorMode(em); + SetThreadErrorMode(em, NULL); #endif *res_handle = apr_pcalloc(ctx, sizeof(**res_handle)); -- cgit v1.2.1