[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Use Get/SetThreadErrorMode if it is available (on Windows 7 and above).
From: |
Peter Rosin |
Subject: |
Use Get/SetThreadErrorMode if it is available (on Windows 7 and above). |
Date: |
Mon, 15 Mar 2010 11:55:16 +0100 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 |
Hi!
A few minutes after pushing the GetErrorMode patch [1] I found out that
Win7 and 2k8R2 have added the functions Get/SetThreadErrorMode which
addresses this concern raised in [2]:
> That said, a potential race is still there since the error mode is
> process global and we are trying to save the current error mode and
> restore it afterwards, some other thread might do the same and we'd get
> into an inconsistent state if unlucky. There's no way to deal with that
> though, short of adding some locking mechanism and requiring client code
> to follow our lead.
This patch makes use of the new functions if they are available and
falls back to the previous behavior if they are not (i.e. use GetErrorMode
if it is available, otherwise simulate it with SetErrorMode).
I have been quite busy lately, so I didn't have time to test it properly
for a number of weeks which is why the commit is oldish. But now I have
done testing (on 2k8R2 with Get/SetThreadErrorMode, on (old) Wine with
GetErrorMode and on XP without GetErrorMode) and it behaves as desired.
Recent Wine versions implements Get/SetThreadErrorMode so that was why
I tested with an old Wine version from before the addition of those APIs.
Cheers,
Peter
[1] http://lists.gnu.org/archive/html/libtool-patches/2010-01/msg00004.html
[2] http://lists.gnu.org/archive/html/libtool-patches/2010-01/msg00037.html
2010-01-21 Peter Rosin <address@hidden>
Use Get/SetThreadErrorMode if they are available.
* libltdl/loaders/loadlibrary.c (wrap_geterrormode): Replaced...
(wrap_getthreaderrormode): ...by this function that checks
first for GetThreadErrorMode, then GetErrorMode and makes use
of either of those or...
(fallback_getthreaderrormode): ...else falls back to this
replacement function that implements the old workaround, which
was previously implemented in...
(fallback_geterrormode): ...this now renamed function.
(geterrormode): Replaced...
(getthreaderrormode): ...by this function pointer that points
at either of wrap_getthreaderrormode, GetThreadErrorMode,
GetErrorMode or fallback_getthreaderrormode.
(wrap_setthreaderrormode): New function that checks if
SetThreadErrorMode is supported by the system and makes use of
it if it is.
(fallback_setthreaderrormode): New function that is used
otherwise that implements the old version using SetErrorMode.
(setthreaderrormode): New function pointer that points at
either of wrap_setthreaderrormode, SetThreadErrorMode or
fallback_setthreaderrormode.
(vm_open): Adjust to the above.
--
They are in the crowd with the answer before the question.
> Why do you dislike Jeopardy?
thread-error-mode.patch
Description: Text document
- Use Get/SetThreadErrorMode if it is available (on Windows 7 and above).,
Peter Rosin <=