VirtualBox

Changeset 25724 in vbox for trunk/src/VBox/Runtime/r3/win


Ignore:
Timestamp:
Jan 11, 2010 2:45:34 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56467
Message:

iprt: Use RTMSINTERVAL for timeouts. Fixed missing timeout underflow checks in two RTFileAioCtxWait implementations.

Location:
trunk/src/VBox/Runtime/r3/win
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/fileaio-win.cpp

    r25645 r25724  
    386386}
    387387
    388 RTDECL(int) RTFileAioCtxWait(RTFILEAIOCTX hAioCtx, size_t cMinReqs, unsigned cMillisTimeout,
     388RTDECL(int) RTFileAioCtxWait(RTFILEAIOCTX hAioCtx, size_t cMinReqs, RTMSINTERVAL cMillies,
    389389                             PRTFILEAIOREQ pahReqs, size_t cReqs, uint32_t *pcReqs)
    390390{
     
    417417    int cRequestsCompleted = 0;
    418418    while (   !pCtxInt->fWokenUp
    419            && (cMinReqs > 0))
     419           && cMinReqs > 0)
    420420    {
    421421        uint64_t     StartNanoTS = 0;
    422         DWORD        dwTimeout = cMillisTimeout == RT_INDEFINITE_WAIT ? INFINITE : cMillisTimeout;
     422        DWORD        dwTimeout = cMillies == RT_INDEFINITE_WAIT ? INFINITE : cMillies;
    423423        DWORD        cbTransfered;
    424424        LPOVERLAPPED pOverlapped;
     
    426426        BOOL         fSucceeded;
    427427
    428         if (cMillisTimeout != RT_INDEFINITE_WAIT)
     428        if (cMillies != RT_INDEFINITE_WAIT)
    429429            StartNanoTS = RTTimeNanoTS();
    430430
     
    446446        if (lCompletionKey == AIO_CONTEXT_WAKEUP_EVENT)
    447447            break;
    448         else
     448
     449        /* A request completed. */
     450        PRTFILEAIOREQINTERNAL pReqInt = OVERLAPPED_2_RTFILEAIOREQINTERNAL(pOverlapped);
     451        AssertPtr(pReqInt);
     452        Assert(pReqInt->u32Magic == RTFILEAIOREQ_MAGIC);
     453
     454        /* Mark the request as finished. */
     455        RTFILEAIOREQ_SET_STATE(pReqInt, COMPLETED);
     456
     457        /* completion status. */
     458        DWORD cbTransfered;
     459        fSucceeded = GetOverlappedResult(pReqInt->hFile,
     460                                         &pReqInt->Overlapped,
     461                                         &cbTransfered,
     462                                         FALSE);
     463        pReqInt->cbTransfered = cbTransfered;
     464        pReqInt->Rc = VINF_SUCCESS;
     465
     466        pahReqs[cRequestsCompleted++] = (RTFILEAIOREQ)pReqInt;
     467
     468        /* Update counter. */
     469        cMinReqs--;
     470
     471        if (cMillies != RT_INDEFINITE_WAIT)
    449472        {
    450             /* A request completed. */
    451             PRTFILEAIOREQINTERNAL pReqInt = OVERLAPPED_2_RTFILEAIOREQINTERNAL(pOverlapped);
    452             AssertPtr(pReqInt);
    453             Assert(pReqInt->u32Magic == RTFILEAIOREQ_MAGIC);
    454 
    455             /* Mark the request as finished. */
    456             RTFILEAIOREQ_SET_STATE(pReqInt, COMPLETED);
    457 
    458             /* completion status. */
    459             DWORD cbTransfered;
    460             fSucceeded = GetOverlappedResult(pReqInt->hFile,
    461                                              &pReqInt->Overlapped,
    462                                              &cbTransfered,
    463                                              FALSE);
    464             pReqInt->cbTransfered = cbTransfered;
    465             pReqInt->Rc = VINF_SUCCESS;
    466 
    467             pahReqs[cRequestsCompleted++] = (RTFILEAIOREQ)pReqInt;
    468 
    469             /* Update counter. */
    470             cMinReqs --;
    471 
    472             if (cMillisTimeout != RT_INDEFINITE_WAIT)
    473             {
    474                 /* Recalculate timeout. */
    475                 uint64_t NanoTS = RTTimeNanoTS();
    476                 uint64_t cMilliesElapsed = (NanoTS - StartNanoTS) / 1000000;
    477                 cMillisTimeout -= cMilliesElapsed;
    478             }
     473            /* Recalculate timeout. */
     474            uint64_t NanoTS = RTTimeNanoTS();
     475            uint64_t cMilliesElapsed = (NanoTS - StartNanoTS) / 1000000;
     476            if (cMilliesElapsed < cMillies)
     477                cMillies -= cMilliesElapsed;
     478            else
     479                cMillies = 0;
    479480        }
    480481    }
  • trunk/src/VBox/Runtime/r3/win/semevent-win.cpp

    r25717 r25724  
    197197
    198198#undef RTSemEventWaitNoResume
    199 RTDECL(int)   RTSemEventWaitNoResume(RTSEMEVENT hEventSem, unsigned cMillies)
     199RTDECL(int)   RTSemEventWaitNoResume(RTSEMEVENT hEventSem, RTMSINTERVAL cMillies)
    200200{
    201201    PCRTLOCKVALSRCPOS pSrcPos = NULL;
  • trunk/src/VBox/Runtime/r3/win/semeventmulti-win.cpp

    r25720 r25724  
    221221
    222222#undef RTSemEventMultiWaitNoResume
    223 RTDECL(int)  RTSemEventMultiWaitNoResume(RTSEMEVENTMULTI hEventMultiSem, unsigned cMillies)
     223RTDECL(int)  RTSemEventMultiWaitNoResume(RTSEMEVENTMULTI hEventMultiSem, RTMSINTERVAL cMillies)
    224224{
    225225    PCRTLOCKVALSRCPOS pSrcPos = NULL;
  • trunk/src/VBox/Runtime/r3/win/semmutex-win.cpp

    r25721 r25724  
    174174 * @param   pSrcPos             The source position of the caller.
    175175 */
    176 DECL_FORCE_INLINE(int) rtSemMutexRequestNoResume(RTSEMMUTEX hMutexSem, unsigned cMillies, PCRTLOCKVALSRCPOS pSrcPos)
     176DECL_FORCE_INLINE(int) rtSemMutexRequestNoResume(RTSEMMUTEX hMutexSem, RTMSINTERVAL cMillies, PCRTLOCKVALSRCPOS pSrcPos)
    177177{
    178178    /*
     
    251251
    252252#undef RTSemMutexRequestNoResume
    253 RTDECL(int) RTSemMutexRequestNoResume(RTSEMMUTEX hMutexSem, unsigned cMillies)
     253RTDECL(int) RTSemMutexRequestNoResume(RTSEMMUTEX hMutexSem, RTMSINTERVAL cMillies)
    254254{
    255255#ifndef RTSEMMUTEX_STRICT
     
    262262
    263263
    264 RTDECL(int) RTSemMutexRequestNoResumeDebug(RTSEMMUTEX hMutexSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
     264RTDECL(int) RTSemMutexRequestNoResumeDebug(RTSEMMUTEX hMutexSem, RTMSINTERVAL cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
    265265{
    266266    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_DEBUG_API();
  • trunk/src/VBox/Runtime/r3/win/thread-win.cpp

    r13837 r25724  
    146146
    147147
    148 RTR3DECL(int)   RTThreadSleep(unsigned cMillies)
     148RTR3DECL(int)   RTThreadSleep(RTMSINTERVAL cMillies)
    149149{
    150150    LogFlow(("RTThreadSleep: cMillies=%d\n", cMillies));
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