VirtualBox

Changeset 37135 in vbox


Ignore:
Timestamp:
May 18, 2011 2:44:47 PM (14 years ago)
Author:
vboxsync
Message:

dev/usb/win: race fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/USB/win/USBProxyDevice-win.cpp

    r37132 r37135  
    617617     */
    618618    PVUSBURB pUrb = NULL;
    619     unsigned cQueuedUrbs = pPriv->cQueuedUrbs;
     619    unsigned cQueuedUrbs;
     620    /* we must get the queued urb count inside a lock
     621     * otherwise we may end up in a situation when cQueuedUrbs is incremented
     622     * by the usbProxyWinAsyncIoThread, but the pPriv->paHandles[cQueuedUrbs-1]
     623     * is still invalid */
     624    RTCritSectEnter(&pPriv->CritSect);
     625    cQueuedUrbs = pPriv->cQueuedUrbs;
     626    RTCritSectLeave(&pPriv->CritSect);
     627
    620628    DWORD rc = WaitForMultipleObjects(cQueuedUrbs, pPriv->paHandles, FALSE, cMillies);
    621629    if (rc >= WAIT_OBJECT_0 && rc < WAIT_OBJECT_0 + cQueuedUrbs)
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