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/modules.c
static rsRetVal modUnlinkAndDestroy(modInfo_t** ppThis)
{
    DEFiRet;
    modInfo_t* pThis;

    assert(ppThis != NULL);
    pThis = *ppThis;
    assert(pThis != NULL);

    pthread_mutex_lock(&mutObjGlobalOp);

    /* first check if we are permitted to unload */
    if (pThis->eType == eMOD_LIB)
    {
        if (pThis->uRefCnt > 0)
        {
            dbgprintf("module %s NOT unloaded because it still has a refcount "
                      "of %u\n",
                      pThis->pszName, pThis->uRefCnt);
            ABORT_FINALIZE(RS_RET_MODULE_STILL_REFERENCED);
        }
    }

    /* we need to unlink the module before we can destruct it -- rgerhards,
     * 2008-02-26 */
    if (pThis->pPrev == NULL)
    {
        /* module is root, so we need to set a new root */
        pLoadedModules = pThis->pNext;
    }
    else
    {
        pThis->pPrev->pNext = pThis->pNext;
    }

    if (pThis->pNext == NULL)
    {
        pLoadedModulesLast = pThis->pPrev;
    }
    else
    {
        pThis->pNext->pPrev = pThis->pPrev;
    }

    /* finally, we are ready for the module to go away... */
    dbgprintf("Unloading module %s\n", modGetName(pThis));
    CHKiRet(modPrepareUnload(pThis));
    *ppThis = pThis->pNext;

    moduleDestruct(pThis);

finalize_it:
    pthread_mutex_unlock(&mutObjGlobalOp);
    RETiRet;
}
/* unlink and destroy a module. The caller must provide a pointer to the module
 * itself as well as one to its immediate predecessor.
 * rgerhards, 2008-02-26
 */
unlink and destroy a module. The caller must provide a pointer to the module
itself as well as one to its immediate predecessor.
unlink and destroy a module . The caller must provide a pointer to the module itself as well as one to its immediate predecessor .
static rsRetVal modUnlinkAndDestroy(modInfo_t** ppThis)
{
    DEFiRet;
    modInfo_t* pThis;
    assert(ppThis != NULL);
    pThis = *ppThis;
    assert(pThis != NULL);
    pthread_mutex_lock(&mutObjGlobalOp);
    if (pThis->eType == eMOD_LIB)
    {
        if (pThis->uRefCnt > 0)
        {
            dbgprintf("module %s NOT unloaded because it still has a refcount "
                      "of %u\n",
                      pThis->pszName, pThis->uRefCnt);
            ABORT_FINALIZE(RS_RET_MODULE_STILL_REFERENCED);
        }
    }
    if (pThis->pPrev == NULL)
    {
        pLoadedModules = pThis->pNext;
    }
    else
    {
        pThis->pPrev->pNext = pThis->pNext;
    }
    if (pThis->pNext == NULL)
    {
        pLoadedModulesLast = pThis->pPrev;
    }
    else
    {
        pThis->pNext->pPrev = pThis->pPrev;
    }
    dbgprintf("Unloading module %s\n", modGetName(pThis));
    CHKiRet(modPrepareUnload(pThis));
    *ppThis = pThis->pNext;
    moduleDestruct(pThis);
finalize_it:
    pthread_mutex_unlock(&mutObjGlobalOp);
    RETiRet;
}
static rsRetVal modUnlinkAndDestroy ( modInfo_t * * ppThis ) { DEFiRet ; modInfo_t * pThis ; assert ( ppThis != NULL ) ; pThis = * ppThis ; assert ( pThis != NULL ) ; pthread_mutex_lock ( & mutObjGlobalOp ) ; if ( pThis -> eType == eMOD_LIB ) { if ( pThis -> uRefCnt > 0 ) { dbgprintf ( " " " \n " , pThis -> pszName , pThis -> uRefCnt ) ; ABORT_FINALIZE ( RS_RET_MODULE_STILL_REFERENCED ) ; } } if ( pThis -> pPrev == NULL ) { pLoadedModules = pThis -> pNext ; } else { pThis -> pPrev -> pNext = pThis -> pNext ; } if ( pThis -> pNext == NULL ) { pLoadedModulesLast = pThis -> pPrev ; } else { pThis -> pNext -> pPrev = pThis -> pPrev ; } dbgprintf ( " \n " , modGetName ( pThis ) ) ; CHKiRet ( modPrepareUnload ( pThis ) ) ; * ppThis = pThis -> pNext ; moduleDestruct ( pThis ) ; finalize_it : pthread_mutex_unlock ( & mutObjGlobalOp ) ; RETiRet ; }
unlink and destroy a module.
unlink and destroy a module .
/* first check if we are permitted to unload */ /* we need to unlink the module before we can destruct it -- rgerhards,
     * 2008-02-26 */ /* module is root, so we need to set a new root */ /* finally, we are ready for the module to go away... */