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/glbl.c
static rsRetVal GenerateLocalHostNameProperty(void)
{
    uchar* pszPrev;
    int lenPrev;
    prop_t* hostnameNew;
    uchar* pszName;
    DEFiRet;

    if (propLocalHostNameToDelete != NULL)
        prop.Destruct(&propLocalHostNameToDelete);

    if (LocalHostNameOverride == NULL)
    {
        if (LocalHostName == NULL)
            pszName = (uchar*)"[localhost]";
        else
        {
            if (GetPreserveFQDN() == 1)
                pszName = LocalFQDNName;
            else
                pszName = LocalHostName;
        }
    }
    else
    { /* local hostname is overriden via config */
        pszName = LocalHostNameOverride;
    }
    DBGPRINTF("GenerateLocalHostName uses '%s'\n", pszName);

    if (propLocalHostName == NULL)
        pszPrev = (uchar*)""; /* make sure strcmp() below does not match */
    else
        prop.GetString(propLocalHostName, &pszPrev, &lenPrev);

    if (ustrcmp(pszPrev, pszName))
    {
        /* we need to update */
        CHKiRet(prop.Construct(&hostnameNew));
        CHKiRet(prop.SetString(hostnameNew, pszName, ustrlen(pszName)));
        CHKiRet(prop.ConstructFinalize(hostnameNew));
        propLocalHostNameToDelete = propLocalHostName;
        propLocalHostName = hostnameNew;
    }

finalize_it:
    RETiRet;
}
/* generate the local hostname property. This must be done after the hostname
 * info has been set as well as PreserveFQDN. rgerhards, 2009-06-30 NOTE: This
 * function tries to avoid locking by not destructing the previous value
 * immediately. This is so that current readers can  continue to use the
 * previous name. Otherwise, we would need to use read/write locks to protect
 * the update process. In order to do so, we save the previous value and delete
 * it when we are called again the next time. Note that this in theory is racy
 * and can lead to a double-free. In practice, however, the window of exposure
 * to trigger this is extremely short and as this functions is very infrequently
 * being called (on HUP), the trigger condition for this bug is so highly
 * unlikely that it never occurs in practice. Probably if you HUP rsyslog every
 * few milliseconds, but who does that... To further reduce risk potential, we
 * do only update the property when there actually is a hostname change, which
 * makes it even less likely. rgerhards, 2013-10-28
 */
generate the local hostname property. This must be done after the hostname
info has been set as well as PreserveFQDN. rgerhards, 2009-06-30 NOTE: This
function tries to avoid locking by not destructing the previous value
immediately. This is so that current readers can  continue to use the
previous name. Otherwise, we would need to use read/write locks to protect
the update process. In order to do so, we save the previous value and delete
it when we are called again the next time. Note that this in theory is racy
and can lead to a double-free. In practice, however, the window of exposure
to trigger this is extremely short and as this functions is very infrequently
being called (on HUP), the trigger condition for this bug is so highly
unlikely that it never occurs in practice. Probably if you HUP rsyslog every
few milliseconds, but who does that... To further reduce risk potential, we
do only update the property when there actually is a hostname change, which
makes it even less likely.
generate the local hostname property . This must be done after the hostname info has been set as well as PreserveFQDN . rgerhards 2009 - 06 - 30 NOTE : This function tries to avoid locking by not destructing the previous value immediately . This is so that current readers can continue to use the previous name . Otherwise we would need to use read / write locks to protect the update process . In order to do so we save the previous value and delete it when we are called again the next time . Note that this in theory is racy and can lead to a double - free . In practice however the window of exposure to trigger this is extremely short and as this functions is very infrequently being called ( on HUP ) the trigger condition for this bug is so highly unlikely that it never occurs in practice . Probably if you HUP rsyslog every few milliseconds but who does that ... To further reduce risk potential we do only update the property when there actually is a hostname change which makes it even less likely .
static rsRetVal GenerateLocalHostNameProperty(void)
{
    uchar* pszPrev;
    int lenPrev;
    prop_t* hostnameNew;
    uchar* pszName;
    DEFiRet;
    if (propLocalHostNameToDelete != NULL)
        prop.Destruct(&propLocalHostNameToDelete);
    if (LocalHostNameOverride == NULL)
    {
        if (LocalHostName == NULL)
            pszName = (uchar*)"[localhost]";
        else
        {
            if (GetPreserveFQDN() == 1)
                pszName = LocalFQDNName;
            else
                pszName = LocalHostName;
        }
    }
    else
    { 
        pszName = LocalHostNameOverride;
    }
    DBGPRINTF("GenerateLocalHostName uses '%s'\n", pszName);
    if (propLocalHostName == NULL)
        pszPrev = (uchar*)""; 
    else
        prop.GetString(propLocalHostName, &pszPrev, &lenPrev);
    if (ustrcmp(pszPrev, pszName))
    {
        CHKiRet(prop.Construct(&hostnameNew));
        CHKiRet(prop.SetString(hostnameNew, pszName, ustrlen(pszName)));
        CHKiRet(prop.ConstructFinalize(hostnameNew));
        propLocalHostNameToDelete = propLocalHostName;
        propLocalHostName = hostnameNew;
    }
finalize_it:
    RETiRet;
}
static rsRetVal GenerateLocalHostNameProperty ( void ) { uchar * pszPrev ; int lenPrev ; prop_t * hostnameNew ; uchar * pszName ; DEFiRet ; if ( propLocalHostNameToDelete != NULL ) prop . Destruct ( & propLocalHostNameToDelete ) ; if ( LocalHostNameOverride == NULL ) { if ( LocalHostName == NULL ) pszName = ( uchar * ) " " ; else { if ( GetPreserveFQDN ( ) == 1 ) pszName = LocalFQDNName ; else pszName = LocalHostName ; } } else { pszName = LocalHostNameOverride ; } DBGPRINTF ( " \n " , pszName ) ; if ( propLocalHostName == NULL ) pszPrev = ( uchar * ) " " ; else prop . GetString ( propLocalHostName , & pszPrev , & lenPrev ) ; if ( ustrcmp ( pszPrev , pszName ) ) { CHKiRet ( prop . Construct ( & hostnameNew ) ) ; CHKiRet ( prop . SetString ( hostnameNew , pszName , ustrlen ( pszName ) ) ) ; CHKiRet ( prop . ConstructFinalize ( hostnameNew ) ) ; propLocalHostNameToDelete = propLocalHostName ; propLocalHostName = hostnameNew ; } finalize_it : RETiRet ; }
generate the local hostname property.
generate the local hostname property .
/* local hostname is overriden via config */ /* make sure strcmp() below does not match */ /* we need to update */