VirtualBox

Ignore:
Timestamp:
Apr 27, 2010 2:05:25 PM (15 years ago)
Author:
vboxsync
Message:

IntNet,VBoxNetFlt: Cleaned up the locking protocol between IntNet and NetFlt. Eleminated the out-bound trunk lock that IntNet always took when calling NetFlt.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/darwin/VBoxNetFlt-darwin.cpp

    r28800 r28830  
    233233     * Be careful here to avoid problems racing the detached callback.
    234234     */
    235     RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
     235    RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
    236236    if (!ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost))
    237237    {
     
    240240            ifnet_reference(pIfNet);
    241241    }
    242     RTSpinlockRelease(pThis->hSpinlock, &Tmp);
     242    RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
    243243
    244244    return pIfNet;
     
    664664     * behind it in order to avoid problematic races with the detached callback.
    665665     */
    666     RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
     666    RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
    667667
    668668    pIfNet = (ifnet_t)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pIfNet);
     
    677677    ASMAtomicWriteBool(&pThis->fDisconnectedFromHost, true);
    678678
    679     RTSpinlockRelease(pThis->hSpinlock, &Tmp);
     679    RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
    680680
    681681    if (pIfNet)
     
    817817     * Active? Retain the instance and increment the busy counter.
    818818     */
    819     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    820     RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
    821     const bool fActive = ASMAtomicUoReadBool(&pThis->fActive);
    822     if (fActive)
    823         vboxNetFltRetain(pThis, true /* fBusy */);
    824     RTSpinlockRelease(pThis->hSpinlock, &Tmp);
    825     if (!fActive)
     819    if (!vboxNetFltTryRetainBusyActive(pThis))
    826820        return 0;
    827821
     
    919913
    920914    RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    921     RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
     915    RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
    922916    ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.pIfNet, pIfNet);
    923     RTSpinlockRelease(pThis->hSpinlock, &Tmp);
     917    RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
    924918
    925919    /*
     
    945939        Assert(err || pIfFilter);
    946940
    947         RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
     941        RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
    948942        pIfNet = (ifnet_t)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pIfNet);
    949943        if (pIfNet && !err)
     
    953947            pIfNet = NULL; /* don't dereference it */
    954948        }
    955         RTSpinlockRelease(pThis->hSpinlock, &Tmp);
     949        RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
    956950
    957951        /* Report capabilities. */
    958         if (!pIfNet)
     952        if (   !pIfNet
     953            && vboxNetFltTryRetainBusyNotDisconnected(pThis))
    959954        {
    960955            Assert(pThis->pSwitchPort);
     
    963958            pThis->pSwitchPort->pfnReportGsoCapabilities(pThis->pSwitchPort, 0,  INTNETTRUNKDIR_WIRE | INTNETTRUNKDIR_HOST);
    964959            pThis->pSwitchPort->pfnReportNoPreemptDsts(pThis->pSwitchPort, 0 /* none */);
     960            vboxNetFltRelease(pThis, true /*fBusy*/);
    965961        }
    966962    }
     
    11631159     * Carefully obtain the interface filter reference and detach it.
    11641160     */
    1165     RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
     1161    RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
    11661162    pIfFilter = (interface_filter_t)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pIfFilter);
    11671163    if (pIfFilter)
    11681164        ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.pIfFilter, NULL);
    1169     RTSpinlockRelease(pThis->hSpinlock, &Tmp);
     1165    RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
    11701166
    11711167    if (pIfFilter)
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