VirtualBox

Changeset 69942 in vbox


Ignore:
Timestamp:
Dec 5, 2017 11:40:31 PM (7 years ago)
Author:
vboxsync
Message:

iprt/vfs: Made RTVFSFILEOPS::pfnPollOne optional.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/vfslowlevel.h

    r69844 r69942  
    883883     *                      should be hidden from the caller (@c false).
    884884     * @param   pfRetEvents Where to return the event mask.
     885     * @note    Optional.  If NULL, immediately return all requested non-error
     886     *          events, waiting for errors works like sleep.
    885887     * @sa      RTPollSetAdd, RTPoll, RTPollNoResume.
    886888     */
  • trunk/src/VBox/Runtime/common/dvm/dvmvfs.cpp

    r69906 r69942  
    324324
    325325/**
    326  * @interface_method_impl{RTVFSIOSTREAMOPS,pfnPollOne}
    327  */
    328 static DECLCALLBACK(int) rtDvmVfsFile_PollOne(void *pvThis, uint32_t fEvents, RTMSINTERVAL cMillies, bool fIntr,
    329                                               uint32_t *pfRetEvents)
    330 {
    331     NOREF(pvThis);
    332     int rc;
    333     if (fEvents != RTPOLL_EVT_ERROR)
    334     {
    335         *pfRetEvents = fEvents & ~RTPOLL_EVT_ERROR;
    336         rc = VINF_SUCCESS;
    337     }
    338     else
    339         rc = RTVfsUtilDummyPollOne(fEvents, cMillies, fIntr, pfRetEvents);
    340     return rc;
    341 }
    342 
    343 
    344 /**
    345326 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnTell}
    346327 */
     
    481462        rtDvmVfsFile_Write,
    482463        rtDvmVfsFile_Flush,
    483         rtDvmVfsFile_PollOne,
     464        NULL /*pfnPollOne*/,
    484465        rtDvmVfsFile_Tell,
    485466        NULL /*Skip*/,
  • trunk/src/VBox/Runtime/common/fs/isomaker.cpp

    r69941 r69942  
    72707270
    72717271/**
    7272  * @interface_method_impl{RTVFSIOSTREAMOPS,pfnPollOne}
    7273  */
    7274 static DECLCALLBACK(int) rtFsIsoMakerOutFile_PollOne(void *pvThis, uint32_t fEvents, RTMSINTERVAL cMillies, bool fIntr,
    7275                                                      uint32_t *pfRetEvents)
    7276 {
    7277     NOREF(pvThis);
    7278     return RTVfsUtilDummyPollOne(fEvents, cMillies, fIntr, pfRetEvents);
    7279 }
    7280 
    7281 
    7282 /**
    72837272 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnTell}
    72847273 */
     
    74157404        rtFsIsoMakerOutFile_Write,
    74167405        rtFsIsoMakerOutFile_Flush,
    7417         rtFsIsoMakerOutFile_PollOne,
     7406        NULL /*PollOne*/,
    74187407        rtFsIsoMakerOutFile_Tell,
    74197408        rtFsIsoMakerOutFile_Skip,
  • trunk/src/VBox/Runtime/common/vfs/vfsbase.cpp

    r69861 r69942  
    4040#include <iprt/param.h>
    4141#include <iprt/path.h>
     42#include <iprt/poll.h>
    4243#include <iprt/semaphore.h>
    4344#include <iprt/thread.h>
     
    114115        AssertPtr((pIoStreamOps)->pfnWrite); \
    115116        AssertPtr((pIoStreamOps)->pfnFlush); \
    116         AssertPtr((pIoStreamOps)->pfnPollOne); \
     117        AssertPtrNull((pIoStreamOps)->pfnPollOne); \
    117118        AssertPtr((pIoStreamOps)->pfnTell); \
    118119        AssertPtrNull((pIoStreamOps)->pfnSkip); \
     
    36473648    AssertReturn(pThis->uMagic == RTVFSIOSTREAM_MAGIC, VERR_INVALID_HANDLE);
    36483649
    3649     RTVfsLockAcquireWrite(pThis->Base.hLock);
    3650     int rc = pThis->pOps->pfnPollOne(pThis->Base.pvThis, fEvents, cMillies, fIntr, pfRetEvents);
    3651     RTVfsLockReleaseWrite(pThis->Base.hLock);
     3650    int rc;
     3651    if (pThis->pOps->pfnPollOne)
     3652    {
     3653        RTVfsLockAcquireWrite(pThis->Base.hLock);
     3654        rc = pThis->pOps->pfnPollOne(pThis->Base.pvThis, fEvents, cMillies, fIntr, pfRetEvents);
     3655        RTVfsLockReleaseWrite(pThis->Base.hLock);
     3656    }
     3657    /*
     3658     * Default implementation.  Polling for non-error events returns
     3659     * immediately, waiting for errors will work like sleep.
     3660     */
     3661    else if (fEvents != RTPOLL_EVT_ERROR)
     3662    {
     3663        *pfRetEvents = fEvents & ~RTPOLL_EVT_ERROR;
     3664        rc = VINF_SUCCESS;
     3665    }
     3666    else if (fIntr)
     3667        rc = RTThreadSleep(cMillies);
     3668    else
     3669    {
     3670        uint64_t uMsStart = RTTimeMilliTS();
     3671        do
     3672            rc = RTThreadSleep(cMillies);
     3673        while (   rc == VERR_INTERRUPTED
     3674               && !fIntr
     3675               && RTTimeMilliTS() - uMsStart < cMillies);
     3676        if (rc == VERR_INTERRUPTED)
     3677            rc = VERR_TIMEOUT;
     3678    }
    36523679    return rc;
    36533680}
  • trunk/src/VBox/Runtime/common/vfs/vfsmemory.cpp

    r69111 r69942  
    551551
    552552/**
    553  * @interface_method_impl{RTVFSIOSTREAMOPS,pfnPollOne}
    554  */
    555 static DECLCALLBACK(int) rtVfsMemFile_PollOne(void *pvThis, uint32_t fEvents, RTMSINTERVAL cMillies, bool fIntr,
    556                                               uint32_t *pfRetEvents)
    557 {
    558     NOREF(pvThis);
    559     int rc;
    560     if (fEvents != RTPOLL_EVT_ERROR)
    561     {
    562         *pfRetEvents = fEvents & ~RTPOLL_EVT_ERROR;
    563         rc = VINF_SUCCESS;
    564     }
    565     else
    566         rc = RTVfsUtilDummyPollOne(fEvents, cMillies, fIntr, pfRetEvents);
    567     return rc;
    568 }
    569 
    570 
    571 /**
    572553 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnTell}
    573554 */
     
    718699        rtVfsMemFile_Write,
    719700        rtVfsMemFile_Flush,
    720         rtVfsMemFile_PollOne,
     701        NULL /*PollOne*/,
    721702        rtVfsMemFile_Tell,
    722703        NULL /*Skip*/,
  • trunk/src/VBox/Storage/VDIfVfs.cpp

    r69500 r69942  
    161161
    162162/**
    163  * @interface_method_impl{RTVFSIOSTREAMOPS,pfnPollOne}
    164  */
    165 static DECLCALLBACK(int) vdIfVfsIos_PollOne(void *pvThis, uint32_t fEvents, RTMSINTERVAL cMillies, bool fIntr,
    166                                             uint32_t *pfRetEvents)
    167 {
    168     NOREF(pvThis);
    169     int rc;
    170     if (fEvents != RTPOLL_EVT_ERROR)
    171     {
    172         *pfRetEvents = fEvents & ~RTPOLL_EVT_ERROR;
    173         rc = VINF_SUCCESS;
    174     }
    175     else
    176         rc = RTVfsUtilDummyPollOne(fEvents, cMillies, fIntr, pfRetEvents);
    177     return rc;
    178 }
    179 
    180 
    181 /**
    182163 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnTell}
    183164 */
     
    208189    vdIfVfsIos_Write,
    209190    vdIfVfsIos_Flush,
    210     vdIfVfsIos_PollOne,
     191    NULL /*PollOne*/,
    211192    vdIfVfsIos_Tell,
    212193    NULL /*Skip*/,
     
    366347        vdIfVfsIos_Write,
    367348        vdIfVfsIos_Flush,
    368         vdIfVfsIos_PollOne,
     349        NULL /*PollOne*/,
    369350        vdIfVfsIos_Tell,
    370351        NULL /*Skip*/,
  • trunk/src/VBox/Storage/VDVfs.cpp

    r69602 r69942  
    386386
    387387/**
    388  * @interface_method_impl{RTVFSIOSTREAMOPS,pfnPollOne}
    389  */
    390 static DECLCALLBACK(int) vdVfsFile_PollOne(void *pvThis, uint32_t fEvents, RTMSINTERVAL cMillies, bool fIntr,
    391                                            uint32_t *pfRetEvents)
    392 {
    393     NOREF(pvThis);
    394     int rc;
    395     if (fEvents != RTPOLL_EVT_ERROR)
    396     {
    397         *pfRetEvents = fEvents & ~RTPOLL_EVT_ERROR;
    398         rc = VINF_SUCCESS;
    399     }
    400     else
    401         rc = RTVfsUtilDummyPollOne(fEvents, cMillies, fIntr, pfRetEvents);
    402     return rc;
    403 }
    404 
    405 
    406 /**
    407388 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnTell}
    408389 */
     
    541522        vdVfsFile_Write,
    542523        vdVfsFile_Flush,
    543         vdVfsFile_PollOne,
     524        NULL /*PollOne*/,
    544525        vdVfsFile_Tell,
    545526        NULL /*Skip*/,
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