VirtualBox

Changeset 52393 in vbox for trunk/src/VBox/Devices/Network


Ignore:
Timestamp:
Aug 15, 2014 8:47:35 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95549
Message:

intnet: Fixed bug in intnetR0TrunkIfPortDisconnect where the mutex handle was gotten thru pNetwork in the RTSemMutexRelease call. Updated the documentation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp

    r52134 r52393  
    50155015{
    50165016    PINTNETTRUNKIF pThis = INTNET_SWITCHPORT_2_TRUNKIF(pSwitchPort);
    5017     /*
    5018      * We intentionally do not increase the busy count of the trunk as it will cause a deadlock
    5019      * with a racing intnetR0NetworkDestruct. It is safe to do only due to the fact that our
    5020      * caller must have increased the busy count of the corresponding netflt instance thus
    5021      * preventing intnetR0NetworkDestruct from destroying the trunk.
     5017
     5018    /*
     5019     * The caller has marked the trunk instance busy on his side before making
     5020     * the call (see method docs) to let us safely grab the network and internal
     5021     * network instance pointers without racing the network destruction code
     5022     * (intnetR0TrunkIfDestroy (called by intnetR0TrunkIfDestroy) will wait for
     5023     * the interface to stop being busy before setting pNetwork to NULL and
     5024     * freeing up the resources).
    50225025     */
    50235026    PINTNETNETWORK pNetwork = pThis->pNetwork;
    50245027    if (pNetwork)
    50255028    {
    5026         /*
    5027          * We need to save pIntNet too in case pNetwork becomes invalid while we are waiting
    5028          * on pIntNet->hMtxCreateOpenDestroy.
    5029          */
    50305029        PINTNET pIntNet = pNetwork->pIntNet;
    50315030        Assert(pNetwork->pIntNet);
     5031
    50325032        /*
    5033          * We must decrease the busy count of corresponing netflt instance here allowing
    5034          * intnetR0NetworkDestruct to proceed with destruction.
     5033         * We must decrease the callers busy count here to prevent deadlocking
     5034         * when requesting the big mutex ownership.  This will of course
     5035         * unblock anyone stuck in intnetR0TrunkIfDestroy doing pfnWaitForIdle
     5036         * (the other deadlock party), so we have to revalidate the network
     5037         * pointer after taking ownership of the big mutex.
    50355038         */
    5036         pThis->pIfPort->pfnRelease(pThis->pIfPort, true);
    5037         /* Take the big create/open/destroy sem. */
     5039        pThis->pIfPort->pfnRelease(pThis->pIfPort, true /*fBusy*/);
     5040
    50385041        RTSemMutexRequest(pIntNet->hMtxCreateOpenDestroy, RT_INDEFINITE_WAIT);
    5039         /*
    5040          * At this point pNetwork may no longer exist, being destroyed by intnetR0NetworkDestruct
    5041          * so we need to make sure it is still valid by looking it up in pIntNet->pNetworks.
    5042          */
     5042
    50435043        if (intnetR0NetworkIsValid(pIntNet, pNetwork))
    50445044        {
     5045            Assert(pNetwork->MacTab.pTrunk == pThis); /* Must be valid as long as tehre are no concurrent calls to this method. */
     5046
     5047            /*
     5048             * Disconnect the trunk and destroy it, similar to what is done int
     5049             * intnetR0NetworkDestruct.
     5050             */
    50455051            pThis->pIfPort->pfnSetState(pThis->pIfPort, INTNETTRUNKIFSTATE_DISCONNECTING);
    50465052
     
    50525058        }
    50535059
    5054         RTSemMutexRelease(pNetwork->pIntNet->hMtxCreateOpenDestroy);
     5060        RTSemMutexRelease(pIntNet->hMtxCreateOpenDestroy);
    50555061    }
    50565062}
     
    52815287        pThis->pIfPort = NULL;
    52825288
    5283         /* wait in portions so we can complain ever now an then. */
     5289        /* wait in portions so we can complain every now an then. */
    52845290        uint64_t StartTS = RTTimeSystemNanoTS();
    52855291        int rc = pIfPort->pfnWaitForIdle(pIfPort, 10*1000);
     
    53155321     * Free up the resources.
    53165322     */
    5317     pThis->pNetwork   = NULL;
     5323    pThis->pNetwork = NULL; /* Must not be cleared while busy, see intnetR0TrunkIfPortDisconnect. */
    53185324    RTSpinlockDestroy(pThis->hDstTabSpinlock);
    53195325    for (unsigned i = 0; i < RT_ELEMENTS(pThis->apTaskDstTabs); i++)
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette