Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

static KU32 kldrDyldModUnloadPrerequisitesOne ( PKLDRDYLDMOD  pMod  )  [static]

Worker for kldrDyldModUnloadPrerequisites.

Returns:
The number of modules that now can be unloaded.
Parameters:
pMod The module in question.

Definition at line 614 of file kLdrDyldMod.c.

References KLDRDYLDMOD::cDepRefs, KLDRDYLDMOD::cDynRefs, KLDRDYLDMOD::cPrereqs, KLDRDYLDMOD::cRefs, KLDRDYLDMOD::enmState, KLDRDYLDMOD_ASSERT, kldrDyldModUnlink(), KLDRSTATE_FIXED_UP, KLDRSTATE_GOOD, KLDRSTATE_INITIALIZATION_FAILED, KLDRSTATE_LOADED_PREREQUISITES, KLDRSTATE_PENDING_DESTROY, KLDRSTATE_PENDING_GC, KLDRSTATE_PENDING_INITIALIZATION, KLDRSTATE_PENDING_TERMINATION, KLDRSTATE_RELOADED_FIXED_UP, KLDRSTATE_RELOADED_LOADED_PREREQUISITES, NULL, and KLDRDYLDMOD::papPrereqs.

Referenced by kldrDyldModUnloadPrerequisites().

{
    PKLDRDYLDMOD    pMod2;
    KU32            cToUnload = 0;
    KU32            i;

    KLDRDYLDMOD_ASSERT(pMod->papPrereqs || !pMod->cPrereqs);

    /*
     * Release the one in this module.
     */
    for (i = 0; i < pMod->cPrereqs; i++)
    {
        pMod2 = pMod->papPrereqs[i];
        if (pMod2)
        {
            pMod->papPrereqs[i] = NULL;

            /* do the derefering ourselves or we'll end up in a recursive loop here. */
            KLDRDYLDMOD_ASSERT(pMod2->cDepRefs > 0);
            KLDRDYLDMOD_ASSERT(pMod2->cRefs >= pMod2->cDepRefs);
            pMod2->cDepRefs--;
            pMod2->cRefs--;
            cToUnload += !pMod2->cDepRefs && !pMod2->cDynRefs;
        }
    }

    /*
     * Change the state
     */
    switch (pMod->enmState)
    {
        case KLDRSTATE_LOADED_PREREQUISITES:
        case KLDRSTATE_FIXED_UP:
            pMod->enmState = KLDRSTATE_PENDING_DESTROY;
            kldrDyldModUnlink(pMod);
            break;

        case KLDRSTATE_PENDING_INITIALIZATION:
            pMod->enmState = KLDRSTATE_PENDING_GC;
            break;

        case KLDRSTATE_RELOADED_FIXED_UP:
        case KLDRSTATE_RELOADED_LOADED_PREREQUISITES:
        case KLDRSTATE_GOOD:
            pMod->enmState = KLDRSTATE_PENDING_TERMINATION;
            break;

        case KLDRSTATE_INITIALIZATION_FAILED:
            break;

        default:
            KLDRDYLDMOD_ASSERT(!"invalid state");
            break;
    }

    return cToUnload;
}


Generated by  Doxygen 1.6.0   Back to index