VirtualBox

Changeset 66075 in vbox


Ignore:
Timestamp:
Mar 14, 2017 9:30:32 AM (8 years ago)
Author:
vboxsync
Message:

Devices/Storage/DrvHostBase-win: Wait for the media change thread to terminate before continuing to avoid races

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DrvHostBase-win.cpp

    r65079 r66075  
    539539
    540540
    541 DECLHIDDEN(int) drvHostBasePollerWakeupOs(PDRVHOSTBASE pThis)
    542 {
    543     if (pThis->Os.hwndDeviceChange)
    544         PostMessage(pThis->Os.hwndDeviceChange, WM_CLOSE, 0, 0); /* default win proc will destroy the window */
    545 
    546     return VINF_SUCCESS;
    547 }
    548 
    549 
    550541DECLHIDDEN(int) drvHostBaseQueryMediaStatusOs(PDRVHOSTBASE pThis, bool *pfMediaChanged, bool *pfMediaPresent)
    551542{
     
    565556DECLHIDDEN(void) drvHostBaseDestructOs(PDRVHOSTBASE pThis)
    566557{
     558    /*
     559     * Terminate the thread.
     560     */
     561    if (pThis->Os.hThrdMediaChange != NIL_RTTHREAD)
     562    {
     563        int rc;
     564        int cTimes = 50;
     565        do
     566        {
     567            if (pThis->hwndDeviceChange)
     568                PostMessage(pThis->hwndDeviceChange, WM_CLOSE, 0, 0); /* default win proc will destroy the window */
     569
     570            rc = RTThreadWait(pThis->Os.hThrdMediaChange, 100, NULL);
     571        } while (cTimes-- > 0 && rc == VERR_TIMEOUT);
     572
     573        if (RT_SUCCESS(rc))
     574            pThis->Os.hThrdMediaChange = NIL_RTTHREAD;
     575    }
     576
    567577    /*
    568578     * Unlock the drive if we've locked it or we're in passthru mode.
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette