VirtualBox

Changeset 36015 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 17, 2011 3:10:32 PM (14 years ago)
Author:
vboxsync
Message:

Main-OVF: fix exporting to slow medias

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/ApplianceImplIO.cpp

    r35368 r36015  
    9393 ******************************************************************************/
    9494
    95 #define STATUS_WAIT  UINT32_C(0)
    96 #define STATUS_WRITE UINT32_C(1)
    97 #define STATUS_READ  UINT32_C(2)
    98 #define STATUS_END   UINT32_C(3)
     95#define STATUS_WAIT    UINT32_C(0)
     96#define STATUS_WRITE   UINT32_C(1)
     97#define STATUS_WRITING UINT32_C(2)
     98#define STATUS_READ    UINT32_C(3)
     99#define STATUS_READING UINT32_C(4)
     100#define STATUS_END     UINT32_C(5)
    99101
    100102/* Enable for getting some flow history. */
     
    491493            case STATUS_WRITE:
    492494            {
     495                ASMAtomicCmpXchgU32(&pInt->u32Status, STATUS_WRITING, STATUS_WRITE);
    493496                size_t cbAvail = RTCircBufUsed(pInt->pCircBuf);
    494497                size_t cbMemAllRead = 0;
     
    536539                 * are finished. Use CmpXchg, so we not overwrite other states
    537540                 * which could be signaled in the meantime. */
    538                 ASMAtomicCmpXchgU32(&pInt->u32Status, STATUS_WAIT, STATUS_WRITE);
    539                 rc = RTSemEventSignal(pInt->workFinishedEvent);
     541                if (ASMAtomicCmpXchgU32(&pInt->u32Status, STATUS_WAIT, STATUS_WRITING))
     542                    rc = RTSemEventSignal(pInt->workFinishedEvent);
    540543                break;
    541544            }
    542545            case STATUS_READ:
    543546            {
     547                ASMAtomicCmpXchgU32(&pInt->u32Status, STATUS_READING, STATUS_READ);
    544548                size_t cbAvail = RTCircBufFree(pInt->pCircBuf);
    545549                size_t cbMemAllWrite = 0;
     
    594598                 * are finished. Use CmpXchg, so we not overwrite other states
    595599                 * which could be signaled in the meantime. */
    596                 ASMAtomicCmpXchgU32(&pInt->u32Status, STATUS_WAIT, STATUS_READ);
    597                 rc = RTSemEventSignal(pInt->workFinishedEvent);
     600                if (ASMAtomicCmpXchgU32(&pInt->u32Status, STATUS_WAIT, STATUS_READING))
     601                    rc = RTSemEventSignal(pInt->workFinishedEvent);
    598602                break;
    599603            }
     
    606610        }
    607611    }
     612    /* Cleanup any status changes to indicate we are finished. */
     613    ASMAtomicWriteU32(&pInt->u32Status, STATUS_END);
     614    rc = RTSemEventSignal(pInt->workFinishedEvent);
    608615    return rc;
    609616}
     
    623630//        RTPrintf(" wait\n");
    624631        if (!(   ASMAtomicReadU32(&pInt->u32Status) == STATUS_WRITE
    625               || ASMAtomicReadU32(&pInt->u32Status) == STATUS_READ))
     632              || ASMAtomicReadU32(&pInt->u32Status) == STATUS_WRITING
     633              || ASMAtomicReadU32(&pInt->u32Status) == STATUS_READ
     634              || ASMAtomicReadU32(&pInt->u32Status) == STATUS_READING))
    626635            break;
    627636        rc = RTSemEventWait(pInt->workFinishedEvent, 100);
     
    678687        pInt->fEOF         = false;
    679688        pInt->fOpenMode    = fOpen;
     689        pInt->u32Status    = STATUS_WAIT;
    680690
    681691        /* Circular buffer in the read case. */
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