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/iminternal.c
rsRetVal iminternalAddMsg(smsg_t* pMsg)
{
    DEFiRet;
    iminternal_t* pThis = NULL;
    struct timespec to;
    int r;
    int is_locked = 0;

    /* we guard against deadlock, so we can guarantee rsyslog will never
     * block due to internal messages. The 1 second timeout should be
     * sufficient under all circumstances.
     */
    to.tv_sec = time(NULL) + 1;
    to.tv_nsec = 0;
#if !defined(__APPLE__)
    r = pthread_mutex_timedlock(&mutList, &to);
#else
    r = pthread_mutex_trylock(&mutList); // must check
#endif
    is_locked = 1;
    if (r != 0)
    {
        dbgprintf(
            "iminternalAddMsg: timedlock for mutex failed with %d, msg %s\n", r,
            getMSG(pMsg));
        /* the message is lost, nothing we can do against this! */
        msgDestruct(&pMsg);
        ABORT_FINALIZE(RS_RET_ERR);
    }
    CHKiRet(iminternalConstruct(&pThis));
    pThis->pMsg = pMsg;
    CHKiRet(llAppend(&llMsgs, NULL, (void*)pThis));

    if (bHaveMainQueue)
    {
        DBGPRINTF("signaling new internal message via SIGTTOU: '%s'\n",
                  pThis->pMsg->pszRawMsg);
        kill(glblGetOurPid(), SIGTTOU);
    }

finalize_it:
    if (is_locked)
    {
        pthread_mutex_unlock(&mutList);
    }
    if (iRet != RS_RET_OK)
    {
        dbgprintf("iminternalAddMsg() error %d - can not otherwise report this "
                  "error, message lost\n",
                  iRet);
        if (pThis != NULL)
            iminternalDestruct(pThis);
    }

    RETiRet;
}
/* add a message to the linked list
 * Note: the pMsg reference counter is not incremented. Consequently,
 * the caller must NOT decrement it. The caller actually hands over
 * full ownership of the pMsg object.
 */
add a message to the linked list
Note: the pMsg reference counter is not incremented. Consequently,
the caller must NOT decrement it. The caller actually hands over
full ownership of the pMsg object.
add a message to the linked list Note : the pMsg reference counter is not incremented . Consequently the caller must NOT decrement it . The caller actually hands over full ownership of the pMsg object .
rsRetVal iminternalAddMsg(smsg_t* pMsg)
{
    DEFiRet;
    iminternal_t* pThis = NULL;
    struct timespec to;
    int r;
    int is_locked = 0;
    to.tv_sec = time(NULL) + 1;
    to.tv_nsec = 0;
#if !defined(__APPLE__)
    r = pthread_mutex_timedlock(&mutList, &to);
#else
    r = pthread_mutex_trylock(&mutList); 
#endif
    is_locked = 1;
    if (r != 0)
    {
        dbgprintf(
            "iminternalAddMsg: timedlock for mutex failed with %d, msg %s\n", r,
            getMSG(pMsg));
        msgDestruct(&pMsg);
        ABORT_FINALIZE(RS_RET_ERR);
    }
    CHKiRet(iminternalConstruct(&pThis));
    pThis->pMsg = pMsg;
    CHKiRet(llAppend(&llMsgs, NULL, (void*)pThis));
    if (bHaveMainQueue)
    {
        DBGPRINTF("signaling new internal message via SIGTTOU: '%s'\n",
                  pThis->pMsg->pszRawMsg);
        kill(glblGetOurPid(), SIGTTOU);
    }
finalize_it:
    if (is_locked)
    {
        pthread_mutex_unlock(&mutList);
    }
    if (iRet != RS_RET_OK)
    {
        dbgprintf("iminternalAddMsg() error %d - can not otherwise report this "
                  "error, message lost\n",
                  iRet);
        if (pThis != NULL)
            iminternalDestruct(pThis);
    }
    RETiRet;
}
rsRetVal iminternalAddMsg ( smsg_t * pMsg ) { DEFiRet ; iminternal_t * pThis = NULL ; struct timespec to ; int r ; int is_locked = 0 ; to . tv_sec = time ( NULL ) + 1 ; to . tv_nsec = 0 ; #if ! defined ( __APPLE__ ) r = pthread_mutex_timedlock ( & mutList , & to ) ; #else r = pthread_mutex_trylock ( & mutList ) ; #endif is_locked = 1 ; if ( r != 0 ) { dbgprintf ( " \n " , r , getMSG ( pMsg ) ) ; msgDestruct ( & pMsg ) ; ABORT_FINALIZE ( RS_RET_ERR ) ; } CHKiRet ( iminternalConstruct ( & pThis ) ) ; pThis -> pMsg = pMsg ; CHKiRet ( llAppend ( & llMsgs , NULL , ( void * ) pThis ) ) ; if ( bHaveMainQueue ) { DBGPRINTF ( " \n " , pThis -> pMsg -> pszRawMsg ) ; kill ( glblGetOurPid ( ) , SIGTTOU ) ; } finalize_it : if ( is_locked ) { pthread_mutex_unlock ( & mutList ) ; } if ( iRet != RS_RET_OK ) { dbgprintf ( " " " \n " , iRet ) ; if ( pThis != NULL ) iminternalDestruct ( pThis ) ; } RETiRet ; }
add a message to the linked list
 Note: the pMsg reference counter is not incremented.
add a message to the linked list Note : the pMsg reference counter is not incremented .
/* we guard against deadlock, so we can guarantee rsyslog will never
     * block due to internal messages. The 1 second timeout should be
     * sufficient under all circumstances.
     */ // must check /* the message is lost, nothing we can do against this! */