VirtualBox

Changeset 97084 in vbox for trunk/src/VBox/NetworkServices


Ignore:
Timestamp:
Oct 11, 2022 6:51:17 AM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
154035
Message:

NetworkServices/IntNetSwitch: Some fixes and cleanups, bugref:10297

Location:
trunk/src/VBox/NetworkServices/IntNetSwitch
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/IntNetSwitch/IntNetSwitchInternal.h

    r97058 r97084  
    3636*   Header Files                                                                                                                 *
    3737*********************************************************************************************************************************/
     38#define IN_INTNET_TESTCASE
     39#define IN_INTNET_R3
     40
    3841#include <VBox/cdefs.h>
    3942#include <VBox/types.h>
     
    4649#define PSUPDRVSESSION  MYPSUPDRVSESSION
    4750
     51#include <VBox/intnet.h>
    4852#include <VBox/sup.h>
    4953
  • trunk/src/VBox/NetworkServices/IntNetSwitch/SrvIntNetWrapper.cpp

    r97059 r97084  
    3333*   Header Files                                                                                                                 *
    3434*********************************************************************************************************************************/
    35 #define IN_INTNET_TESTCASE
    36 #define IN_INTNET_R3
    37 
    3835#include "IntNetSwitchInternal.h"
    3936
    40 
    41 #include <VBox/types.h>
    42 #include <VBox/intnet.h>
    4337#include <iprt/asm.h>
    4438#include <iprt/mp.h>
  • trunk/src/VBox/NetworkServices/IntNetSwitch/main.cpp

    r97079 r97084  
    3737#include "IntNetSwitchInternal.h"
    3838
    39 #include <VBox/intnet.h>
    4039#include <VBox/err.h>
    4140#include <VBox/vmm/vmm.h>
    4241#include <iprt/asm.h>
     42#include <iprt/critsect.h>
    4343#include <iprt/initterm.h>
    4444#include <iprt/mem.h>
     
    5555*   Structures and Typedefs                                                                                                      *
    5656*********************************************************************************************************************************/
    57 
    5857
    5958/**
     
    9897    /** Number of references to this service. */
    9998    uint32_t volatile               cRefs;
    100     /** Mutex to serialize the initialization, usage counting and objects. */
    101     RTSEMFASTMUTEX                  hMtx;
     99    /** Critical section to serialize the initialization, usage counting and objects. */
     100    RTCRITSECT                      CritSect;
    102101    /** List of registered objects. Protected by the spinlock. */
    103102    PSUPDRVOBJ volatile             pObjs;
     
    113112{
    114113    PSUPDRVDEVEXT                   pDevExt;
    115     /** List of generic usage records. (protected by SUPDRVDEVEXT::hMtx) */
     114    /** List of generic usage records. (protected by SUPDRVDEVEXT::CritSect) */
    116115    PSUPDRVUSAGE volatile           pUsage;
    117116    /** The XPC connection handle for this session. */
     
    158157
    159158    PSUPDRVDEVEXT pDevExt = pSession->pDevExt;
    160     RTSemFastMutexRequest(pDevExt->hMtx);
     159    RTCritSectEnter(&pDevExt->CritSect);
    161160
    162161    /* The object. */
     
    170169    pSession->pUsage    = pUsage;
    171170
    172     RTSemFastMutexRelease(pDevExt->hMtx);
     171    RTCritSectLeave(&pDevExt->CritSect);
    173172    return pObj;
    174173}
     
    184183    RT_NOREF(fNoBlocking);
    185184
    186     RTSemFastMutexRequest(pDevExt->hMtx);
     185    RTCritSectEnter(&pDevExt->CritSect);
    187186
    188187    /*
     
    220219    }
    221220
    222     RTSemFastMutexRelease(pDevExt->hMtx);
     221    RTCritSectLeave(&pDevExt->CritSect);
    223222    return rc;
    224223}
     
    242241     * Acquire the spinlock and look for the usage record.
    243242     */
    244     RTSemFastMutexRequest(pDevExt->hMtx);
     243    RTCritSectEnter(&pDevExt->CritSect);
    245244
    246245    for (pUsagePrev = NULL, pUsage = pSession->pUsage;
     
    296295    }
    297296
    298     RTSemFastMutexRelease(pDevExt->hMtx);
     297    RTCritSectLeave(&pDevExt->CritSect);
    299298
    300299    /*
     
    380379    {
    381380        PSUPDRVUSAGE  pUsage;
    382         RTSemFastMutexRequest(pDevExt->hMtx);
     381        RTCritSectEnter(&pDevExt->CritSect);
    383382
    384383        while ((pUsage = pSession->pUsage) != NULL)
     
    409408                }
    410409
     410                RTCritSectLeave(&pDevExt->CritSect);
     411
    411412                if (pObj->pfnDestructor)
    412413                    pObj->pfnDestructor(pObj, pObj->pvUser1, pObj->pvUser2);
    413414                RTMemFree(pObj);
     415
     416                RTCritSectEnter(&pDevExt->CritSect);
    414417            }
    415418
     
    418421        }
    419422
    420         RTSemFastMutexRelease(pDevExt->hMtx);
     423        RTCritSectLeave(&pDevExt->CritSect);
    421424        AssertMsg(!pSession->pUsage, ("Some buster reregistered an object during desturction!\n"));
    422425    }
     
    448451            break;
    449452
    450         INTNETIFWAITREQ WaitReq;
    451         WaitReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC;
    452         WaitReq.Hdr.cbReq    = sizeof(WaitReq);
    453         WaitReq.pSession     = NULL;
    454         WaitReq.hIf          = pSession->hIfWait;
    455         WaitReq.cMillies     = 30000; /* 30s - don't wait forever, timeout now and then. */
    456         int rc = IntNetR0IfWaitReq(pSession, &WaitReq);
     453        int rc = IntNetR0IfWait(pSession->hIfWait, pSession, 30000); /* 30s - don't wait forever, timeout now and then. */
    457454        if (RT_SUCCESS(rc))
    458455        {
     
    464461                 && rc != VERR_INTERRUPTED)
    465462        {
    466             LogFlow(("drvR3IntNetRecvRun: returns %Rrc\n", rc));
     463            LogFlow(("intnetR3RecvThread: returns %Rrc\n", rc));
    467464            return rc;
    468465        }
     
    635632                {
    636633                    /* Last one cleans up the global data. */
    637                     RTSemFastMutexDestroy(pDevExt->hMtx);
    638                     pDevExt->hMtx = NIL_RTSEMFASTMUTEX;
     634                    RTCritSectDelete(&pDevExt->CritSect);
    639635                }
    640636            }
     
    680676
    681677        g_DevExt.pObjs = NULL;
    682         rc = RTSemFastMutexCreate(&g_DevExt.hMtx);
     678        rc = RTCritSectInit(&g_DevExt.CritSect);
    683679        if (RT_SUCCESS(rc))
    684680            xpc_main(xpcConnHandler); /* Never returns. */
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