Changeset 17306 in vbox
- Timestamp:
- Mar 3, 2009 6:23:42 PM (16 years ago)
- Location:
- trunk/src/VBox/HostDrivers/VBoxNetFlt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFlt.c
r17244 r17306 646 646 */ 647 647 rc = RTSemFastMutexRequest(pGlobals->hFastMtx); AssertRC(rc); 648 #if 0 //#ifdef VBOXNETFLT_STATIC_CONFIG 649 /** @todo r=bird: This looks kind of insane! I ASSUME this is specific to the 650 * static config and to devices in the Unconnected state only. This *looks* like 651 * a very unhealthy race between driver unloading and vboxNetFltFactoryCreateAndConnect. 652 * If I'm right, then vboxNetFltFactoryCreateAndConnect should be made to back down one 653 * way or the other, it should not the other way around. (see suggestion further down) 654 * 655 * If I'm wrong, then please explain in full. 656 * 657 * r=misha: this code is to prevent race conditions between PVBOXNETFLTINS construct (which occurs on binding to adapter 658 * rather than on vboxNetFltFactoryCreateAndConnect for static_config) and destruction, 659 * namely the instance returned by vboxNetFltFindInstanceLocked in vboxNetFltSearchCreateInstance could be actually the instance being removed. 660 * I guess an approach similar to what you added to vboxNetFltFactoryCreateAndConnect could be used in vboxNetFltSearchCreateInstance in this case we could remove 661 * this ugly hack. 662 */ 663 if (cRefs != 0) 664 { 665 Assert(cRefs < UINT32_MAX / 2); 666 RTSemFastMutexRelease(pGlobals->hFastMtx); 667 return false; 668 } 648 #ifdef VBOXNETFLT_STATIC_CONFIG 669 649 vboxNetFltSetState(pThis, kVBoxNetFltInsState_Destroying); 670 650 #else … … 1018 998 while (pCur) 1019 999 { 1020 #if 11021 1000 uint32_t cRefs = ASMAtomicIncU32(&pCur->cRefs); 1022 1001 if (cRefs > 1) … … 1087 1066 AssertRCReturn(rc, rc); 1088 1067 1089 #else /* old code: */1090 VBOXNETFTLINSSTATE enmState = vboxNetFltGetState(pCur);1091 if ( enmState != kVBoxNetFltInsState_Destroying1092 && enmState != kVBoxNetFltInsState_Destroyed)1093 {1094 /** @todo r=bird: who is making sure this is a genuine reconnection case? */1095 vboxNetFltRetain(pCur, false /* fBusy */);1096 RTSemFastMutexRelease(pGlobals->hFastMtx);1097 *ppInstance = pCur;1098 return VINF_ALREADY_INITIALIZED;1099 }1100 1101 /* wait 2 ms */ /** @todo r=bird: Doesn't RTThreadSleep() work here? If it's bust, I'd like to know it so we can fix it... */1102 RTSemFastMutexRelease(pGlobals->hFastMtx);1103 RTSemEventWait(pGlobals->hBlockEvent, 2);1104 rc = RTSemFastMutexRequest(pGlobals->hFastMtx);1105 AssertRCReturn(rc, rc);1106 #endif1107 1108 1068 /* try again */ 1109 1069 pCur = vboxNetFltFindInstanceLocked(pGlobals, pszName); … … 1159 1119 { 1160 1120 #ifdef VBOXNETFLT_STATIC_CONFIG 1161 # if 1 /** @todo r=bird: We need to fix the race here. The race is against release+destructor, the1162 * tell tale is a cRefs of and since cRefs is manipulated in an atomic fashion we can simply attempt1163 * to grab a reference atomically, the worst thing that can happen is that we have to decrement it again..1164 * Here is my suggestion: */1165 1121 /* Try grab a reference. If the count had already reached zero we're racing the 1166 1122 destructor code and must back down. */ … … 1189 1145 if (pCur) 1190 1146 vboxNetFltRelease(pCur, false /* fBusy */); 1191 1192 # else1193 if (vboxNetFltGetState(pCur) == kVBoxNetFltInsState_Unconnected)1194 {1195 vboxNetFltRetain(pCur, false /* fBusy */); /** @todo r=bird: Who releases this on failure? */1196 pCur->fDisablePromiscuous = !!(fFlags & INTNETTRUNKFACTORY_FLAG_NO_PROMISC);1197 rc = vboxNetFltConnectIt(pCur, pSwitchPort, ppIfPort);1198 }1199 else1200 rc = VERR_INTNET_FLT_IF_BUSY;1201 RTSemFastMutexRelease(pGlobals->hFastMtx);1202 # endif1203 1147 #else 1204 1148 rc = VERR_INTNET_FLT_IF_BUSY; … … 1403 1347 RTSemFastMutexDestroy(pGlobals->hFastMtx); 1404 1348 pGlobals->hFastMtx = NIL_RTSEMFASTMUTEX; 1405 1406 #ifdef VBOXNETFLT_STATIC_CONFIG1407 RTSemEventDestroy(pGlobals->hBlockEvent);1408 pGlobals->hBlockEvent = NIL_RTSEMEVENT;1409 #endif1410 1411 1349 } 1412 1350 … … 1427 1365 if (RT_SUCCESS(rc)) 1428 1366 { 1429 #ifdef VBOXNETFLT_STATIC_CONFIG 1430 rc = RTSemEventCreate(&pGlobals->hBlockEvent); 1431 if (RT_SUCCESS(rc)) 1432 { 1367 pGlobals->pInstanceHead = NULL; 1368 1369 pGlobals->TrunkFactory.pfnRelease = vboxNetFltFactoryRelease; 1370 pGlobals->TrunkFactory.pfnCreateAndConnect = vboxNetFltFactoryCreateAndConnect; 1371 #if defined(RT_OS_WINDOWS) && defined(VBOX_TAPMINIPORT) 1372 strcpy(pGlobals->SupDrvFactory.szName, "VBoxNetAdp"); 1373 #else 1374 strcpy(pGlobals->SupDrvFactory.szName, "VBoxNetFlt"); 1433 1375 #endif 1434 pGlobals->pInstanceHead = NULL; 1435 1436 pGlobals->TrunkFactory.pfnRelease = vboxNetFltFactoryRelease; 1437 pGlobals->TrunkFactory.pfnCreateAndConnect = vboxNetFltFactoryCreateAndConnect; 1438 #if defined(RT_OS_WINDOWS) && defined(VBOX_TAPMINIPORT) 1439 strcpy(pGlobals->SupDrvFactory.szName, "VBoxNetAdp"); 1440 #else 1441 strcpy(pGlobals->SupDrvFactory.szName, "VBoxNetFlt"); 1442 #endif 1443 pGlobals->SupDrvFactory.pfnQueryFactoryInterface = vboxNetFltQueryFactoryInterface; 1444 pGlobals->fIDCOpen = false; 1445 1446 return rc; 1447 #ifdef VBOXNETFLT_STATIC_CONFIG 1448 } 1449 RTSemFastMutexDestroy(pGlobals->hFastMtx); 1450 #endif 1376 pGlobals->SupDrvFactory.pfnQueryFactoryInterface = vboxNetFltQueryFactoryInterface; 1377 pGlobals->fIDCOpen = false; 1378 1379 return rc; 1451 1380 } 1452 1381 -
trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFltInternal.h
r17186 r17306 262 262 /** The SUPDRV IDC handle (opaque struct). */ 263 263 SUPDRVIDCHANDLE SupDrvIDC; 264 265 #ifdef VBOXNETFLT_STATIC_CONFIG266 /** Something we can block on while waiting for an instance to be unlinked. */267 RTSEMEVENT hBlockEvent;268 #endif269 264 } VBOXNETFLTGLOBALS; 270 265
Note:
See TracChangeset
for help on using the changeset viewer.