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/tools/omfwd.c
static rsRetVal TCPSendFrame(void* pvData, char* msg, size_t len)
{
    DEFiRet;
    wrkrInstanceData_t* pWrkrData = (wrkrInstanceData_t*)pvData;

    DBGPRINTF("omfwd: add %u bytes to send buffer (curr offs %u)\n",
              (unsigned)len, pWrkrData->offsSndBuf);
    if (pWrkrData->offsSndBuf != 0 &&
        pWrkrData->offsSndBuf + len >= sizeof(pWrkrData->sndBuf))
    {
        /* no buffer space left, need to commit previous records. With the
         * current API, there unfortunately is no way to signal this
         * state transition to the upper layer.
         */
        DBGPRINTF("omfwd: we need to do a tcp send due to buffer "
                  "out of space. If the transaction fails, this will "
                  "lead to duplication of messages");
        CHKiRet(TCPSendBuf(pWrkrData, pWrkrData->sndBuf, pWrkrData->offsSndBuf,
                           NO_FLUSH));
        pWrkrData->offsSndBuf = 0;
    }

    /* check if the message is too large to fit into buffer */
    if (len > sizeof(pWrkrData->sndBuf))
    {
        CHKiRet(TCPSendBuf(pWrkrData, (uchar*)msg, len, NO_FLUSH));
        ABORT_FINALIZE(RS_RET_OK); /* committed everything so far */
    }

    /* we now know the buffer has enough free space */
    memcpy(pWrkrData->sndBuf + pWrkrData->offsSndBuf, msg, len);
    pWrkrData->offsSndBuf += len;
    iRet = RS_RET_DEFER_COMMIT;

finalize_it:
    RETiRet;
}
/* Add frame to send buffer (or send, if requried)
 */
Add frame to send buffer (or send, if requried)
Add frame to send buffer ( or send if requried )
static rsRetVal TCPSendFrame(void* pvData, char* msg, size_t len)
{
    DEFiRet;
    wrkrInstanceData_t* pWrkrData = (wrkrInstanceData_t*)pvData;
    DBGPRINTF("omfwd: add %u bytes to send buffer (curr offs %u)\n",
              (unsigned)len, pWrkrData->offsSndBuf);
    if (pWrkrData->offsSndBuf != 0 &&
        pWrkrData->offsSndBuf + len >= sizeof(pWrkrData->sndBuf))
    {
        DBGPRINTF("omfwd: we need to do a tcp send due to buffer "
                  "out of space. If the transaction fails, this will "
                  "lead to duplication of messages");
        CHKiRet(TCPSendBuf(pWrkrData, pWrkrData->sndBuf, pWrkrData->offsSndBuf,
                           NO_FLUSH));
        pWrkrData->offsSndBuf = 0;
    }
    if (len > sizeof(pWrkrData->sndBuf))
    {
        CHKiRet(TCPSendBuf(pWrkrData, (uchar*)msg, len, NO_FLUSH));
        ABORT_FINALIZE(RS_RET_OK); 
    }
    memcpy(pWrkrData->sndBuf + pWrkrData->offsSndBuf, msg, len);
    pWrkrData->offsSndBuf += len;
    iRet = RS_RET_DEFER_COMMIT;
finalize_it:
    RETiRet;
}
static rsRetVal TCPSendFrame ( void * pvData , char * msg , size_t len ) { DEFiRet ; wrkrInstanceData_t * pWrkrData = ( wrkrInstanceData_t * ) pvData ; DBGPRINTF ( " \n " , ( unsigned ) len , pWrkrData -> offsSndBuf ) ; if ( pWrkrData -> offsSndBuf != 0 && pWrkrData -> offsSndBuf + len >= sizeof ( pWrkrData -> sndBuf ) ) { DBGPRINTF ( " " " " " " ) ; CHKiRet ( TCPSendBuf ( pWrkrData , pWrkrData -> sndBuf , pWrkrData -> offsSndBuf , NO_FLUSH ) ) ; pWrkrData -> offsSndBuf = 0 ; } if ( len > sizeof ( pWrkrData -> sndBuf ) ) { CHKiRet ( TCPSendBuf ( pWrkrData , ( uchar * ) msg , len , NO_FLUSH ) ) ; ABORT_FINALIZE ( RS_RET_OK ) ; } memcpy ( pWrkrData -> sndBuf + pWrkrData -> offsSndBuf , msg , len ) ; pWrkrData -> offsSndBuf += len ; iRet = RS_RET_DEFER_COMMIT ; finalize_it : RETiRet ; }
Add frame to send buffer (or send, if requried)
Add frame to send buffer ( or send if requried )
/* no buffer space left, need to commit previous records. With the
         * current API, there unfortunately is no way to signal this
         * state transition to the upper layer.
         */ /* check if the message is too large to fit into buffer */ /* committed everything so far */ /* we now know the buffer has enough free space */