VirtualBox

Changeset 36292 in vbox


Ignore:
Timestamp:
Mar 16, 2011 12:45:59 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
70589
Message:

VD: Fix possible race condition which can lead to hanging I/O requests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/VD.cpp

    r36278 r36292  
    34753475                                  size_t cbCompleted)
    34763476{
     3477    PVDIO    pVDIo = (PVDIO)pvUser;
     3478    PVBOXHDD pDisk = pVDIo->pDisk;
     3479
     3480    /*
     3481     * Grab the disk critical section to avoid races with other threads which
     3482     * might still modify the I/O context.
     3483     * Example is that iSCSI is doing an asynchronous write but calls us already
     3484     * while the other thread is still hanging in vdWriteHelperAsync and couldn't update
     3485     * the fBlocked state yet.
     3486     * It can overwrite the state to true before we call vdIoCtxContinue and the
     3487     * the request would hang indefinite.
     3488     */
     3489    int rc = RTCritSectEnter(&pDisk->CritSect);
     3490    AssertRC(rc);
     3491
    34773492    /* Continue */
    34783493    pIoCtx->fBlocked = false;
     
    34833498    if (!pIoCtx->cbTransferLeft)
    34843499        pIoCtx->pfnIoCtxTransfer = NULL;
     3500
     3501    rc = RTCritSectLeave(&pDisk->CritSect);
     3502    AssertRC(rc);
    34853503
    34863504    vdIoCtxContinue(pIoCtx, rcReq);
Note: See TracChangeset for help on using the changeset viewer.

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