Changeset 52393 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Aug 15, 2014 8:47:35 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 95549
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp
r52134 r52393 5015 5015 { 5016 5016 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). 5022 5025 */ 5023 5026 PINTNETNETWORK pNetwork = pThis->pNetwork; 5024 5027 if (pNetwork) 5025 5028 { 5026 /*5027 * We need to save pIntNet too in case pNetwork becomes invalid while we are waiting5028 * on pIntNet->hMtxCreateOpenDestroy.5029 */5030 5029 PINTNET pIntNet = pNetwork->pIntNet; 5031 5030 Assert(pNetwork->pIntNet); 5031 5032 5032 /* 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. 5035 5038 */ 5036 pThis->pIfPort->pfnRelease(pThis->pIfPort, true );5037 /* Take the big create/open/destroy sem. */ 5039 pThis->pIfPort->pfnRelease(pThis->pIfPort, true /*fBusy*/); 5040 5038 5041 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 5043 5043 if (intnetR0NetworkIsValid(pIntNet, pNetwork)) 5044 5044 { 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 */ 5045 5051 pThis->pIfPort->pfnSetState(pThis->pIfPort, INTNETTRUNKIFSTATE_DISCONNECTING); 5046 5052 … … 5052 5058 } 5053 5059 5054 RTSemMutexRelease(p Network->pIntNet->hMtxCreateOpenDestroy);5060 RTSemMutexRelease(pIntNet->hMtxCreateOpenDestroy); 5055 5061 } 5056 5062 } … … 5281 5287 pThis->pIfPort = NULL; 5282 5288 5283 /* wait in portions so we can complain ever now an then. */5289 /* wait in portions so we can complain every now an then. */ 5284 5290 uint64_t StartTS = RTTimeSystemNanoTS(); 5285 5291 int rc = pIfPort->pfnWaitForIdle(pIfPort, 10*1000); … … 5315 5321 * Free up the resources. 5316 5322 */ 5317 pThis->pNetwork = NULL;5323 pThis->pNetwork = NULL; /* Must not be cleared while busy, see intnetR0TrunkIfPortDisconnect. */ 5318 5324 RTSpinlockDestroy(pThis->hDstTabSpinlock); 5319 5325 for (unsigned i = 0; i < RT_ELEMENTS(pThis->apTaskDstTabs); i++)
Note:
See TracChangeset
for help on using the changeset viewer.