VirtualBox

Changeset 17306 in vbox


Ignore:
Timestamp:
Mar 3, 2009 6:23:42 PM (16 years ago)
Author:
vboxsync
Message:

VBoxNetFlt: Fixed missing transition to the 'destroying' state. Removed disabled code and unused hBlockEvent.

Location:
trunk/src/VBox/HostDrivers/VBoxNetFlt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFlt.c

    r17244 r17306  
    646646     */
    647647    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
    669649    vboxNetFltSetState(pThis, kVBoxNetFltInsState_Destroying);
    670650#else
     
    1018998    while (pCur)
    1019999    {
    1020 #if 1
    10211000        uint32_t cRefs = ASMAtomicIncU32(&pCur->cRefs);
    10221001        if (cRefs > 1)
     
    10871066        AssertRCReturn(rc, rc);
    10881067
    1089 #else /* old code: */
    1090         VBOXNETFTLINSSTATE enmState = vboxNetFltGetState(pCur);
    1091         if (    enmState != kVBoxNetFltInsState_Destroying
    1092             &&  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 #endif
    1107 
    11081068        /* try again */
    11091069        pCur = vboxNetFltFindInstanceLocked(pGlobals, pszName);
     
    11591119    {
    11601120#ifdef VBOXNETFLT_STATIC_CONFIG
    1161 # if 1 /** @todo r=bird: We need to fix the race here. The race is against release+destructor, the
    1162         * tell tale is a cRefs of and since cRefs is manipulated in an atomic fashion we can simply attempt
    1163         * to grab a reference atomically, the worst thing that can happen is that we have to decrement it again..
    1164         * Here is my suggestion: */
    11651121        /* Try grab a reference. If the count had already reached zero we're racing the
    11661122           destructor code and must back down. */
     
    11891145        if (pCur)
    11901146            vboxNetFltRelease(pCur, false /* fBusy */);
    1191 
    1192 # else
    1193         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         else
    1200             rc = VERR_INTNET_FLT_IF_BUSY;
    1201         RTSemFastMutexRelease(pGlobals->hFastMtx);
    1202 # endif
    12031147#else
    12041148        rc = VERR_INTNET_FLT_IF_BUSY;
     
    14031347    RTSemFastMutexDestroy(pGlobals->hFastMtx);
    14041348    pGlobals->hFastMtx = NIL_RTSEMFASTMUTEX;
    1405 
    1406 #ifdef VBOXNETFLT_STATIC_CONFIG
    1407     RTSemEventDestroy(pGlobals->hBlockEvent);
    1408     pGlobals->hBlockEvent = NIL_RTSEMEVENT;
    1409 #endif
    1410 
    14111349}
    14121350
     
    14271365    if (RT_SUCCESS(rc))
    14281366    {
    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");
    14331375#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;
    14511380    }
    14521381
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFltInternal.h

    r17186 r17306  
    262262    /** The SUPDRV IDC handle (opaque struct). */
    263263    SUPDRVIDCHANDLE SupDrvIDC;
    264 
    265 #ifdef VBOXNETFLT_STATIC_CONFIG
    266     /** Something we can block on while waiting for an instance to be unlinked. */
    267     RTSEMEVENT hBlockEvent;
    268 #endif
    269264} VBOXNETFLTGLOBALS;
    270265
Note: See TracChangeset for help on using the changeset viewer.

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