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/plugins/imuxsock/imuxsock.c
static rsRetVal addListner(instanceConf_t* inst)
{
    DEFiRet;

    if (inst->bParseHost == UNSET)
    {
        if (*inst->sockName == ':')
        {
            listeners[nfd].bParseHost = 1;
        }
        else
        {
            listeners[nfd].bParseHost = 0;
        }
    }
    else
    {
        listeners[nfd].bParseHost = inst->bParseHost;
    }
    if (inst->pLogHostName == NULL)
    {
        listeners[nfd].hostName = NULL;
    }
    else
    {
        CHKiRet(prop.Construct(&(listeners[nfd].hostName)));
        CHKiRet(prop.SetString(listeners[nfd].hostName, inst->pLogHostName,
                               ustrlen(inst->pLogHostName)));
        CHKiRet(prop.ConstructFinalize(listeners[nfd].hostName));
    }
    if (inst->ratelimitInterval > 0)
    {
        if ((listeners[nfd].ht =
                 create_hashtable(100, hash_from_key_fn, key_equals_fn,
                                  (void (*)(void*))ratelimitDestruct)) == NULL)
        {
            /* in this case, we simply turn off rate-limiting */
            DBGPRINTF(
                "imuxsock: turning off rate limiting because we could not "
                "create hash table\n");
            inst->ratelimitInterval = 0;
        }
    }
    else
    {
        listeners[nfd].ht = NULL;
    }
    listeners[nfd].ratelimitInterval = inst->ratelimitInterval;
    listeners[nfd].ratelimitBurst = inst->ratelimitBurst;
    listeners[nfd].ratelimitSev = inst->ratelimitSeverity;
    listeners[nfd].flowCtl =
        inst->bUseFlowCtl ? eFLOWCTL_LIGHT_DELAY : eFLOWCTL_NO_DELAY;
    listeners[nfd].flags = inst->bIgnoreTimestamp ? IGNDATE : NOFLAG;
    listeners[nfd].bCreatePath = inst->bCreatePath;
    listeners[nfd].sockName = ustrdup(inst->sockName);
    listeners[nfd].bUseCreds =
        (inst->bDiscardOwnMsgs || inst->bWritePid || inst->ratelimitInterval ||
         inst->bAnnotate || inst->bUseSysTimeStamp)
            ? 1
            : 0;
    listeners[nfd].bAnnotate = inst->bAnnotate;
    listeners[nfd].bParseTrusted = inst->bParseTrusted;
    listeners[nfd].bDiscardOwnMsgs = inst->bDiscardOwnMsgs;
    listeners[nfd].bUnlink = inst->bUnlink;
    listeners[nfd].bWritePid = inst->bWritePid;
    listeners[nfd].bUseSysTimeStamp = inst->bUseSysTimeStamp;
    listeners[nfd].bUseSpecialParser = inst->bUseSpecialParser;
    listeners[nfd].pRuleset = inst->pBindRuleset;
    CHKiRet(ratelimitNew(&listeners[nfd].dflt_ratelimiter, "imuxsock", NULL));
    ratelimitSetLinuxLike(listeners[nfd].dflt_ratelimiter,
                          listeners[nfd].ratelimitInterval,
                          listeners[nfd].ratelimitBurst);
    ratelimitSetSeverity(listeners[nfd].dflt_ratelimiter,
                         listeners[nfd].ratelimitSev);
    nfd++;

finalize_it:
    RETiRet;
}
/* add an additional listen socket.
 * added capability to specify hostname for socket -- rgerhards, 2008-08-01
 */
add an additional listen socket.
added capability to specify hostname for socket -- rgerhards, 2008-08-01
add an additional listen socket . added capability to specify hostname for socket -- rgerhards 2008 - 08 - 01
static rsRetVal addListner(instanceConf_t* inst)
{
    DEFiRet;
    if (inst->bParseHost == UNSET)
    {
        if (*inst->sockName == ':')
        {
            listeners[nfd].bParseHost = 1;
        }
        else
        {
            listeners[nfd].bParseHost = 0;
        }
    }
    else
    {
        listeners[nfd].bParseHost = inst->bParseHost;
    }
    if (inst->pLogHostName == NULL)
    {
        listeners[nfd].hostName = NULL;
    }
    else
    {
        CHKiRet(prop.Construct(&(listeners[nfd].hostName)));
        CHKiRet(prop.SetString(listeners[nfd].hostName, inst->pLogHostName,
                               ustrlen(inst->pLogHostName)));
        CHKiRet(prop.ConstructFinalize(listeners[nfd].hostName));
    }
    if (inst->ratelimitInterval > 0)
    {
        if ((listeners[nfd].ht =
                 create_hashtable(100, hash_from_key_fn, key_equals_fn,
                                  (void (*)(void*))ratelimitDestruct)) == NULL)
        {
            DBGPRINTF(
                "imuxsock: turning off rate limiting because we could not "
                "create hash table\n");
            inst->ratelimitInterval = 0;
        }
    }
    else
    {
        listeners[nfd].ht = NULL;
    }
    listeners[nfd].ratelimitInterval = inst->ratelimitInterval;
    listeners[nfd].ratelimitBurst = inst->ratelimitBurst;
    listeners[nfd].ratelimitSev = inst->ratelimitSeverity;
    listeners[nfd].flowCtl =
        inst->bUseFlowCtl ? eFLOWCTL_LIGHT_DELAY : eFLOWCTL_NO_DELAY;
    listeners[nfd].flags = inst->bIgnoreTimestamp ? IGNDATE : NOFLAG;
    listeners[nfd].bCreatePath = inst->bCreatePath;
    listeners[nfd].sockName = ustrdup(inst->sockName);
    listeners[nfd].bUseCreds =
        (inst->bDiscardOwnMsgs || inst->bWritePid || inst->ratelimitInterval ||
         inst->bAnnotate || inst->bUseSysTimeStamp)
            ? 1
            : 0;
    listeners[nfd].bAnnotate = inst->bAnnotate;
    listeners[nfd].bParseTrusted = inst->bParseTrusted;
    listeners[nfd].bDiscardOwnMsgs = inst->bDiscardOwnMsgs;
    listeners[nfd].bUnlink = inst->bUnlink;
    listeners[nfd].bWritePid = inst->bWritePid;
    listeners[nfd].bUseSysTimeStamp = inst->bUseSysTimeStamp;
    listeners[nfd].bUseSpecialParser = inst->bUseSpecialParser;
    listeners[nfd].pRuleset = inst->pBindRuleset;
    CHKiRet(ratelimitNew(&listeners[nfd].dflt_ratelimiter, "imuxsock", NULL));
    ratelimitSetLinuxLike(listeners[nfd].dflt_ratelimiter,
                          listeners[nfd].ratelimitInterval,
                          listeners[nfd].ratelimitBurst);
    ratelimitSetSeverity(listeners[nfd].dflt_ratelimiter,
                         listeners[nfd].ratelimitSev);
    nfd++;
finalize_it:
    RETiRet;
}
static rsRetVal addListner ( instanceConf_t * inst ) { DEFiRet ; if ( inst -> bParseHost == UNSET ) { if ( * inst -> sockName == ' ' ) { listeners [ nfd ] . bParseHost = 1 ; } else { listeners [ nfd ] . bParseHost = 0 ; } } else { listeners [ nfd ] . bParseHost = inst -> bParseHost ; } if ( inst -> pLogHostName == NULL ) { listeners [ nfd ] . hostName = NULL ; } else { CHKiRet ( prop . Construct ( & ( listeners [ nfd ] . hostName ) ) ) ; CHKiRet ( prop . SetString ( listeners [ nfd ] . hostName , inst -> pLogHostName , ustrlen ( inst -> pLogHostName ) ) ) ; CHKiRet ( prop . ConstructFinalize ( listeners [ nfd ] . hostName ) ) ; } if ( inst -> ratelimitInterval > 0 ) { if ( ( listeners [ nfd ] . ht = create_hashtable ( 100 , hash_from_key_fn , key_equals_fn , ( void ( * ) ( void * ) ) ratelimitDestruct ) ) == NULL ) { DBGPRINTF ( " " " \n " ) ; inst -> ratelimitInterval = 0 ; } } else { listeners [ nfd ] . ht = NULL ; } listeners [ nfd ] . ratelimitInterval = inst -> ratelimitInterval ; listeners [ nfd ] . ratelimitBurst = inst -> ratelimitBurst ; listeners [ nfd ] . ratelimitSev = inst -> ratelimitSeverity ; listeners [ nfd ] . flowCtl = inst -> bUseFlowCtl ? eFLOWCTL_LIGHT_DELAY : eFLOWCTL_NO_DELAY ; listeners [ nfd ] . flags = inst -> bIgnoreTimestamp ? IGNDATE : NOFLAG ; listeners [ nfd ] . bCreatePath = inst -> bCreatePath ; listeners [ nfd ] . sockName = ustrdup ( inst -> sockName ) ; listeners [ nfd ] . bUseCreds = ( inst -> bDiscardOwnMsgs || inst -> bWritePid || inst -> ratelimitInterval || inst -> bAnnotate || inst -> bUseSysTimeStamp ) ? 1 : 0 ; listeners [ nfd ] . bAnnotate = inst -> bAnnotate ; listeners [ nfd ] . bParseTrusted = inst -> bParseTrusted ; listeners [ nfd ] . bDiscardOwnMsgs = inst -> bDiscardOwnMsgs ; listeners [ nfd ] . bUnlink = inst -> bUnlink ; listeners [ nfd ] . bWritePid = inst -> bWritePid ; listeners [ nfd ] . bUseSysTimeStamp = inst -> bUseSysTimeStamp ; listeners [ nfd ] . bUseSpecialParser = inst -> bUseSpecialParser ; listeners [ nfd ] . pRuleset = inst -> pBindRuleset ; CHKiRet ( ratelimitNew ( & listeners [ nfd ] . dflt_ratelimiter , " " , NULL ) ) ; ratelimitSetLinuxLike ( listeners [ nfd ] . dflt_ratelimiter , listeners [ nfd ] . ratelimitInterval , listeners [ nfd ] . ratelimitBurst ) ; ratelimitSetSeverity ( listeners [ nfd ] . dflt_ratelimiter , listeners [ nfd ] . ratelimitSev ) ; nfd ++ ; finalize_it : RETiRet ; }
add an additional listen socket.
add an additional listen socket .
/* in this case, we simply turn off rate-limiting */