VirtualBox

Changeset 90969 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Aug 27, 2021 10:12:22 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
146608
Message:

IPRT/log: Defined the multibuffer flush protocol. bugref:10086

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/log/log.cpp

    r90866 r90969  
    31073107static void rtlogFlush(PRTLOGGERINTERNAL pLoggerInt, bool fNeedSpace)
    31083108{
    3109     PRTLOGBUFFERDESC const pBufDesc   = pLoggerInt->pBufDesc;
    3110     uint32_t               cchToFlush = pBufDesc->offBuf;
    3111     char * const           pchToFlush = pBufDesc->pchBuf;
    3112     uint32_t const         cbBuf      = pBufDesc->cbBuf;
     3109    PRTLOGBUFFERDESC   pBufDesc   = pLoggerInt->pBufDesc;
     3110    uint32_t            cchToFlush = pBufDesc->offBuf;
     3111    char * const        pchToFlush = pBufDesc->pchBuf;
     3112    uint32_t const      cbBuf      = pBufDesc->cbBuf;
    31133113    Assert(pBufDesc->u32Magic == RTLOGBUFFERDESC_MAGIC);
    31143114
     
    31803180        if (pLoggerInt->pfnFlush)
    31813181        {
    3182             /** @todo implement asynchronous buffer switching protocol. */
    3183             bool fDone;
     3182            /*
     3183             * We have a custom flush callback.  Before calling it we must make
     3184             * sure the aux descriptor is up to date.  When we get back, we may
     3185             * need to switch to the next buffer if the current is being flushed
     3186             * asynchronously.  This of course requires there to be more than one
     3187             * buffer.  (The custom flush callback is responsible for making sure
     3188             * the next buffer isn't being flushed before returning.)
     3189             */
    31843190            if (pBufDesc->pAux)
    31853191                pBufDesc->pAux->offBuf = cchToFlush;
    3186             fDone = pLoggerInt->pfnFlush(&pLoggerInt->Core, pBufDesc);
    3187             Assert(fDone == true); RT_NOREF(fDone);
    3188         }
    3189 
    3190         /* empty the buffer. */
     3192            if (!pLoggerInt->pfnFlush(&pLoggerInt->Core, pBufDesc))
     3193            {
     3194                /* advance to the next buffer */
     3195                Assert(pLoggerInt->cBufDescs > 1);
     3196                size_t idxBufDesc = pBufDesc - pLoggerInt->paBufDescs;
     3197                Assert(idxBufDesc < pLoggerInt->cBufDescs);
     3198                idxBufDesc = (idxBufDesc + 1) % pLoggerInt->cBufDescs;
     3199                pLoggerInt->idxBufDesc = (uint8_t)idxBufDesc;
     3200                pLoggerInt->pBufDesc   = pBufDesc = &pLoggerInt->paBufDescs[idxBufDesc];
     3201            }
     3202        }
     3203
     3204        /* Empty the buffer. */
    31913205        pBufDesc->offBuf = 0;
    31923206        if (pBufDesc->pAux)
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