• Michael Stahl's avatar
    vcl: fix Win32 deadlocks from SolarMutexReleaser · 482c52e9
    Michael Stahl yazdı
    To create and destroy thread-affine Win32 Windows and DCs, non-main
    threads SendMessage() special messages like SAL_MSG_CREATEFRAME.
    
    The main thread must handle these messages and return the result to
    un-block the other thread.
    
    This works fine as long as the main thread is in its message loop anyway
    and blocked on GetMessage(); however if the main blocks trying to acquire
    the SolarMutex that is held by the sending thread, deadlock results.
    
    In order to work around this, there is some peculiar code in
    ImplSalYieldMutexAcquireWithWait() to avoid blocking the main thread on
    mpSalYieldMutex but instead block in GetMessage().
    
    The crucial detail is that GetMessage() will immediately dispatch any
    message sent via SendMessage(), which avoids the deadlock.
    
    https://msdn.microsoft.com/en-us/library/windows/desktop/ms644936.aspx
    https://msdn.microsoft.com/en-us/library/windows/desktop/ms644927.aspx
    
    Most of the Win32 WndProc that acquire SolarMutex do so via
    ImplSalYieldMutexAcquireWithWait(), but the main thread may also
    temporarily drop SolarMutex and re-aquire it with the questionable
    SolarMutexReleaser hack, which calls ImplSalAcquireYieldMutex()
    instead, which blocks on mpSalYieldMutex.
    
    Fix SolarMutexReleaser to call a new function
    Application::ReAcquireSolarMutex() that does the right thing here:
    acquire SolarMutex via ImplSalYieldMutexAcquireWithWait().
    
    It turns out that this problem was already fixed before in commit
    6a8fd4c7 but the problem was
    insufficiently documented in the commit and it introduced the bug
    that Application::Reschedule() was called without having the SolarMutex
    locked, which caused timers to run without SolarMutex, so the commit
    was reverted in 1ef17813.
    
    Change-Id: I60aae555a9ee3c6390f584feddbc6b3cb7de0250
    482c52e9
Adı
Son kayıt (commit)
Son güncelleme
..
headlessinst.cxx Loading commit data...
svpbmp.cxx Loading commit data...
svpdata.cxx Loading commit data...
svpdummies.cxx Loading commit data...
svpframe.cxx Loading commit data...
svpgdi.cxx Loading commit data...
svpinst.cxx Loading commit data...
svpprn.cxx Loading commit data...
svptext.cxx Loading commit data...
svptextrender.cxx Loading commit data...
svpvd.cxx Loading commit data...