Changeset 37144 in vbox
- Timestamp:
- May 18, 2011 4:47:44 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/USB/win/USBProxyDevice-win.cpp
r37135 r37144 36 36 #include <iprt/string.h> 37 37 #include <iprt/thread.h> 38 #include <iprt/asm.h> 38 39 #include "../USBProxyDevice.h" 39 40 #include <VBox/usblib.h> … … 617 618 */ 618 619 PVUSBURB pUrb = NULL; 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); 620 unsigned cQueuedUrbs = ASMAtomicReadU32((volatile uint32_t *)&pPriv->cQueuedUrbs); 627 621 628 622 DWORD rc = WaitForMultipleObjects(cQueuedUrbs, pPriv->paHandles, FALSE, cMillies); … … 728 722 { 729 723 /* insert into the queue */ 730 unsigned j = pPriv->cQueuedUrbs ++;724 unsigned j = pPriv->cQueuedUrbs; 731 725 pPriv->paQueuedUrbs[j] = pQUrbWin; 732 pPriv->paHandles[j] = pQUrbWin->overlapped.hEvent; 726 pPriv->paHandles[j] = pQUrbWin->overlapped.hEvent; 727 /* do an atomic increment to allow usbProxyWinUrbReap thread get it outside a lock, 728 * being sure that pPriv->paHandles contains cQueuedUrbs valid handles */ 729 ASMAtomicIncU32((uint32_t volatile *)&pPriv->cQueuedUrbs); 733 730 } 734 731 else
Note:
See TracChangeset
for help on using the changeset viewer.