openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/rsyslog/8.1903.0-r0/rsyslog-8.1903.0/runtime/stream.c
static rsRetVal doAsyncWriteInternal(strm_t* pThis, size_t lenBuf,
                                     const int bFlushZip)
{
    DEFiRet;
    ISOBJ_TYPE_assert(pThis, strm);

    DBGOPRINT((obj_t*)pThis,
              "file %d(%s) doAsyncWriteInternal at begin: "
              "iCnt %d, iEnq %d, bFlushZip %d\n",
              pThis->fd, getFileDebugName(pThis), pThis->iCnt, pThis->iEnq,
              bFlushZip);
    /* the -1 below is important, because we need one buffer for the main
     * thread! */
    while (pThis->iCnt >= STREAM_ASYNC_NUMBUFS - 1)
        d_pthread_cond_wait(&pThis->notFull, &pThis->mut);

    pThis->asyncBuf[pThis->iEnq % STREAM_ASYNC_NUMBUFS].lenBuf = lenBuf;
    pThis->pIOBuf = pThis->asyncBuf[++pThis->iEnq % STREAM_ASYNC_NUMBUFS].pBuf;
    if (!pThis->bFlushNow) /* if we already need to flush, do not overwrite */
        pThis->bFlushNow = bFlushZip;

    pThis->bDoTimedWait =
        0; /* everything written, no need to timeout partial buffer writes */
    if (++pThis->iCnt == 1)
    {
        pthread_cond_signal(&pThis->notEmpty);
        DBGOPRINT((obj_t*)pThis, "doAsyncWriteInternal signaled notEmpty\n");
    }
    DBGOPRINT((obj_t*)pThis,
              "file %d(%s) doAsyncWriteInternal at exit: "
              "iCnt %d, iEnq %d, bFlushZip %d\n",
              pThis->fd, getFileDebugName(pThis), pThis->iCnt, pThis->iEnq,
              bFlushZip);

    RETiRet;
}
/* This function is called to "do" an async write call, what primarily means
 * that the data is handed over to the writer thread (which will then do the
 * actual write in parallel). Note that the stream mutex has already been locked
 * by the strmWrite...() calls. Also note that we always have only a single
 * producer, so we can simply serially assign the next free buffer to it and be
 * sure that the very some producer comes back in sequence to submit the
 * then-filled buffers. This also enables us to timout on partially written
 * buffers. -- rgerhards, 2009-07-06
 */
This function is called to "do" an async write call, what primarily means
that the data is handed over to the writer thread (which will then do the
actual write in parallel). Note that the stream mutex has already been locked
by the strmWrite...() calls. Also note that we always have only a single
producer, so we can simply serially assign the next free buffer to it and be
sure that the very some producer comes back in sequence to submit the
then-filled buffers. This also enables us to timout on partially written
buffers.
This function is called to " do " an async write call what primarily means that the data is handed over to the writer thread ( which will then do the actual write in parallel ) . Note that the stream mutex has already been locked by the strmWrite ... () calls . Also note that we always have only a single producer so we can simply serially assign the next free buffer to it and be sure that the very some producer comes back in sequence to submit the then - filled buffers . This also enables us to timout on partially written buffers .
static rsRetVal doAsyncWriteInternal(strm_t* pThis, size_t lenBuf,
                                     const int bFlushZip)
{
    DEFiRet;
    ISOBJ_TYPE_assert(pThis, strm);
    DBGOPRINT((obj_t*)pThis,
              "file %d(%s) doAsyncWriteInternal at begin: "
              "iCnt %d, iEnq %d, bFlushZip %d\n",
              pThis->fd, getFileDebugName(pThis), pThis->iCnt, pThis->iEnq,
              bFlushZip);
    while (pThis->iCnt >= STREAM_ASYNC_NUMBUFS - 1)
        d_pthread_cond_wait(&pThis->notFull, &pThis->mut);
    pThis->asyncBuf[pThis->iEnq % STREAM_ASYNC_NUMBUFS].lenBuf = lenBuf;
    pThis->pIOBuf = pThis->asyncBuf[++pThis->iEnq % STREAM_ASYNC_NUMBUFS].pBuf;
    if (!pThis->bFlushNow) 
        pThis->bFlushNow = bFlushZip;
    pThis->bDoTimedWait =
        0; 
    if (++pThis->iCnt == 1)
    {
        pthread_cond_signal(&pThis->notEmpty);
        DBGOPRINT((obj_t*)pThis, "doAsyncWriteInternal signaled notEmpty\n");
    }
    DBGOPRINT((obj_t*)pThis,
              "file %d(%s) doAsyncWriteInternal at exit: "
              "iCnt %d, iEnq %d, bFlushZip %d\n",
              pThis->fd, getFileDebugName(pThis), pThis->iCnt, pThis->iEnq,
              bFlushZip);
    RETiRet;
}
static rsRetVal doAsyncWriteInternal ( strm_t * pThis , size_t lenBuf , const int bFlushZip ) { DEFiRet ; ISOBJ_TYPE_assert ( pThis , strm ) ; DBGOPRINT ( ( obj_t * ) pThis , " " " \n " , pThis -> fd , getFileDebugName ( pThis ) , pThis -> iCnt , pThis -> iEnq , bFlushZip ) ; while ( pThis -> iCnt >= STREAM_ASYNC_NUMBUFS - 1 ) d_pthread_cond_wait ( & pThis -> notFull , & pThis -> mut ) ; pThis -> asyncBuf [ pThis -> iEnq % STREAM_ASYNC_NUMBUFS ] . lenBuf = lenBuf ; pThis -> pIOBuf = pThis -> asyncBuf [ ++ pThis -> iEnq % STREAM_ASYNC_NUMBUFS ] . pBuf ; if ( ! pThis -> bFlushNow ) pThis -> bFlushNow = bFlushZip ; pThis -> bDoTimedWait = 0 ; if ( ++ pThis -> iCnt == 1 ) { pthread_cond_signal ( & pThis -> notEmpty ) ; DBGOPRINT ( ( obj_t * ) pThis , " \n " ) ; } DBGOPRINT ( ( obj_t * ) pThis , " " " \n " , pThis -> fd , getFileDebugName ( pThis ) , pThis -> iCnt , pThis -> iEnq , bFlushZip ) ; RETiRet ; }
This function is called to "do" an async write call, what primarily means
 that the data is handed over to the writer thread (which will then do the
 actual write in parallel).
This function is called to " do " an async write call what primarily means that the data is handed over to the writer thread ( which will then do the actual write in parallel ) .
/* the -1 below is important, because we need one buffer for the main
     * thread! */ /* if we already need to flush, do not overwrite */ /* everything written, no need to timeout partial buffer writes */