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/tcpsrv.c
static rsRetVal doReceive(tcpsrv_t* pThis, tcps_sess_t** ppSess,
                          nspoll_t* pPoll)
{
    char buf[128 * 1024]; /* reception buffer - may hold a partial or multiple
                             messages */
    ssize_t iRcvd;
    rsRetVal localRet;
    DEFiRet;
    uchar* pszPeer;
    int lenPeer;
    int oserr = 0;

    ISOBJ_TYPE_assert(pThis, tcpsrv);
    DBGPRINTF("netstream %p with new data\n", (*ppSess)->pStrm);
    /* Receive message */
    iRet = pThis->pRcvData(*ppSess, buf, sizeof(buf), &iRcvd, &oserr);
    switch (iRet)
    {
        case RS_RET_CLOSED:
            if (pThis->bEmitMsgOnClose)
            {
                errno = 0;
                prop.GetString((*ppSess)->fromHostIP, &pszPeer, &lenPeer);
                LogError(0, RS_RET_PEER_CLOSED_CONN,
                         "Netstream session %p closed by remote "
                         "peer %s.\n",
                         (*ppSess)->pStrm, pszPeer);
            }
            CHKiRet(closeSess(pThis, ppSess, pPoll));
            break;
        case RS_RET_RETRY:
            /* we simply ignore retry - this is not an error, but we also have
             * not received anything */
            break;
        case RS_RET_OK:
            /* valid data received, process it! */
            localRet = tcps_sess.DataRcvd(*ppSess, buf, iRcvd);
            if (localRet != RS_RET_OK && localRet != RS_RET_QUEUE_FULL)
            {
                /* in this case, something went awfully wrong.
                 * We are instructed to terminate the session.
                 */
                prop.GetString((*ppSess)->fromHostIP, &pszPeer, &lenPeer);
                LogError(oserr, localRet, "Tearing down TCP Session from %s",
                         pszPeer);
                CHKiRet(closeSess(pThis, ppSess, pPoll));
            }
            break;
        default:
            prop.GetString((*ppSess)->fromHostIP, &pszPeer, &lenPeer);
            LogError(oserr, iRet,
                     "netstream session %p from %s will be closed due to error",
                     (*ppSess)->pStrm, pszPeer);
            CHKiRet(closeSess(pThis, ppSess, pPoll));
            break;
    }

finalize_it:
    RETiRet;
}
/* process a receive request on one of the streams
 * If pPoll is non-NULL, we have a netstream in epoll mode, which means we need
 * to remove any descriptor we close from the epoll set.
 * rgerhards, 2009-07-020
 */
process a receive request on one of the streams
If pPoll is non-NULL, we have a netstream in epoll mode, which means we need
to remove any descriptor we close from the epoll set.
process a receive request on one of the streams If pPoll is non - NULL we have a netstream in epoll mode which means we need to remove any descriptor we close from the epoll set .
static rsRetVal doReceive(tcpsrv_t* pThis, tcps_sess_t** ppSess,
                          nspoll_t* pPoll)
{
    char buf[128 * 1024]; 
    ssize_t iRcvd;
    rsRetVal localRet;
    DEFiRet;
    uchar* pszPeer;
    int lenPeer;
    int oserr = 0;
    ISOBJ_TYPE_assert(pThis, tcpsrv);
    DBGPRINTF("netstream %p with new data\n", (*ppSess)->pStrm);
    iRet = pThis->pRcvData(*ppSess, buf, sizeof(buf), &iRcvd, &oserr);
    switch (iRet)
    {
        case RS_RET_CLOSED:
            if (pThis->bEmitMsgOnClose)
            {
                errno = 0;
                prop.GetString((*ppSess)->fromHostIP, &pszPeer, &lenPeer);
                LogError(0, RS_RET_PEER_CLOSED_CONN,
                         "Netstream session %p closed by remote "
                         "peer %s.\n",
                         (*ppSess)->pStrm, pszPeer);
            }
            CHKiRet(closeSess(pThis, ppSess, pPoll));
            break;
        case RS_RET_RETRY:
            break;
        case RS_RET_OK:
            localRet = tcps_sess.DataRcvd(*ppSess, buf, iRcvd);
            if (localRet != RS_RET_OK && localRet != RS_RET_QUEUE_FULL)
            {
                prop.GetString((*ppSess)->fromHostIP, &pszPeer, &lenPeer);
                LogError(oserr, localRet, "Tearing down TCP Session from %s",
                         pszPeer);
                CHKiRet(closeSess(pThis, ppSess, pPoll));
            }
            break;
        default:
            prop.GetString((*ppSess)->fromHostIP, &pszPeer, &lenPeer);
            LogError(oserr, iRet,
                     "netstream session %p from %s will be closed due to error",
                     (*ppSess)->pStrm, pszPeer);
            CHKiRet(closeSess(pThis, ppSess, pPoll));
            break;
    }
finalize_it:
    RETiRet;
}
static rsRetVal doReceive ( tcpsrv_t * pThis , tcps_sess_t * * ppSess , nspoll_t * pPoll ) { char buf [ 128 * 1024 ] ; ssize_t iRcvd ; rsRetVal localRet ; DEFiRet ; uchar * pszPeer ; int lenPeer ; int oserr = 0 ; ISOBJ_TYPE_assert ( pThis , tcpsrv ) ; DBGPRINTF ( " \n " , ( * ppSess ) -> pStrm ) ; iRet = pThis -> pRcvData ( * ppSess , buf , sizeof ( buf ) , & iRcvd , & oserr ) ; switch ( iRet ) { case RS_RET_CLOSED : if ( pThis -> bEmitMsgOnClose ) { errno = 0 ; prop . GetString ( ( * ppSess ) -> fromHostIP , & pszPeer , & lenPeer ) ; LogError ( 0 , RS_RET_PEER_CLOSED_CONN , " " " \n " , ( * ppSess ) -> pStrm , pszPeer ) ; } CHKiRet ( closeSess ( pThis , ppSess , pPoll ) ) ; break ; case RS_RET_RETRY : break ; case RS_RET_OK : localRet = tcps_sess . DataRcvd ( * ppSess , buf , iRcvd ) ; if ( localRet != RS_RET_OK && localRet != RS_RET_QUEUE_FULL ) { prop . GetString ( ( * ppSess ) -> fromHostIP , & pszPeer , & lenPeer ) ; LogError ( oserr , localRet , " " , pszPeer ) ; CHKiRet ( closeSess ( pThis , ppSess , pPoll ) ) ; } break ; default : prop . GetString ( ( * ppSess ) -> fromHostIP , & pszPeer , & lenPeer ) ; LogError ( oserr , iRet , " " , ( * ppSess ) -> pStrm , pszPeer ) ; CHKiRet ( closeSess ( pThis , ppSess , pPoll ) ) ; break ; } finalize_it : RETiRet ; }
process a receive request on one of the streams
 If pPoll is non-NULL, we have a netstream in epoll mode, which means we need
 to remove any descriptor we close from the epoll set.
process a receive request on one of the streams If pPoll is non - NULL we have a netstream in epoll mode which means we need to remove any descriptor we close from the epoll set .
/* reception buffer - may hold a partial or multiple
                             messages */ /* Receive message */ /* we simply ignore retry - this is not an error, but we also have
             * not received anything */ /* valid data received, process it! */ /* in this case, something went awfully wrong.
                 * We are instructed to terminate the session.
                 */