VirtualBox

Changeset 101924 in vbox


Ignore:
Timestamp:
Nov 7, 2023 10:19:23 AM (15 months ago)
Author:
vboxsync
Message:

libs/xpcom/ipcDConnectService: Convert to use RTSEMFASTMUTEX for locking, bugref:10545

Location:
trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp

    r93910 r101924  
    24002400    // mCachedISupports, but NSPR doesn't provide cross-platform cmpxchg
    24012401    // functionality, so we have to use a shared lock instead...
    2402     PR_Lock(dConnect->StubQILock());
     2402    RTSemFastMutexRequest(dConnect->StubQILock());
    24032403
    24042404    // check if we have already got a nsISupports stub for this object
     
    24082408      NS_ADDREF(mCachedISupports);
    24092409
    2410       PR_Unlock(dConnect->StubQILock());
     2410      RTSemFastMutexRelease(dConnect->StubQILock());
    24112411      return NS_OK;
    24122412    }
     
    24292429        mCachedISupports = this;
    24302430
    2431         PR_Unlock(dConnect->StubQILock());
     2431        RTSemFastMutexRelease(dConnect->StubQILock());
    24322432        return NS_OK;
    24332433      }
     
    24762476    }
    24772477
    2478     PR_Unlock(dConnect->StubQILock());
     2478    RTSemFastMutexRelease(dConnect->StubQILock());
    24792479  }
    24802480
     
    30093009
    30103010ipcDConnectService::ipcDConnectService()
    3011  : mLock(NULL)
    3012  , mStubLock(NULL)
     3011 : mLock(NIL_RTSEMFASTMUTEX)
     3012 , mStubLock(NIL_RTSEMFASTMUTEX)
    30133013 , mDisconnected(PR_TRUE)
    3014  , mStubQILock(NULL)
     3014 , mStubQILock(NIL_RTSEMFASTMUTEX)
    30153015#if defined(DCONNECT_WITH_IPRT_REQ_POOL)
    30163016 , mhReqPool(NIL_RTREQPOOL)
     
    30483048
    30493049  mInstance = nsnull;
    3050   PR_DestroyLock(mStubQILock);
    3051   PR_DestroyLock(mStubLock);
    3052   PR_DestroyLock(mLock);
     3050  if (mStubQILock != NIL_RTSEMFASTMUTEX)
     3051    RTSemFastMutexDestroy(mStubQILock);
     3052  if (mStubLock != NIL_RTSEMFASTMUTEX)
     3053    RTSemFastMutexDestroy(mStubLock);
     3054  if (mLock != NIL_RTSEMFASTMUTEX)
     3055    RTSemFastMutexDestroy(mLock);
     3056
    30533057#if defined(DCONNECT_WITH_IPRT_REQ_POOL)
    30543058  RTReqPoolRelease(mhReqPool);
     
    30743078    return rv;
    30753079
    3076   mLock = PR_NewLock();
    3077   if (!mLock)
     3080  int vrc = RTSemFastMutexCreate(&mLock);
     3081  if (RT_FAILURE(vrc))
    30783082    return NS_ERROR_OUT_OF_MEMORY;
    30793083
     
    30833087    return NS_ERROR_OUT_OF_MEMORY;
    30843088
    3085   mStubLock = PR_NewLock();
    3086   if (!mStubLock)
     3089  vrc = RTSemFastMutexCreate(&mStubLock);
     3090  if (RT_FAILURE(vrc))
    30873091    return NS_ERROR_OUT_OF_MEMORY;
    30883092
     
    30943098    return rv;
    30953099
    3096   mStubQILock = PR_NewLock();
    3097   if (!mStubQILock)
     3100  vrc = RTSemFastMutexCreate(&mStubQILock);
     3101  if (RT_FAILURE(vrc))
    30983102    return NS_ERROR_OUT_OF_MEMORY;
    30993103
     
    33323336{
    33333337  if (!locked)
    3334     PR_Lock(mLock);
     3338    RTSemFastMutexRequest(mLock);
    33353339
    33363340#ifdef IPC_LOGGING
     
    33483352
    33493353  if (!locked)
    3350     PR_Unlock(mLock);
     3354    RTSemFastMutexRelease(mLock);
    33513355}
    33523356
  • trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.h

    r52046 r101924  
    258258  NS_HIDDEN_(PRBool)   CheckInstanceAndAddRef(DConnectInstance *, PRUint32);
    259259
    260   PRLock *StubLock() { return mStubLock; }
    261   PRLock *StubQILock() { return mStubQILock; }
     260  RTSEMFASTMUTEX StubLock() { return mStubLock; }
     261  RTSEMFASTMUTEX StubQILock() { return mStubQILock; }
    262262
    263263  static nsRefPtr <ipcDConnectService> GetInstance() {
     
    295295
    296296  // lock to protect access to instance sets and the disconnected flag
    297   PRLock *mLock;
     297  RTSEMFASTMUTEX mLock;
    298298
    299299  // table of local object instances allocated on behalf of a peer
     
    306306  // lock to protect access to mStubs and DConnectStub::mRefCntLevels
    307307  // (also guards every DConnectStub::Release call to provide atomicity)
    308   PRLock *mStubLock;
     308  RTSEMFASTMUTEX mStubLock;
    309309
    310310  // table of remote object stubs allocated to communicate with peer's instances
     
    324324  // (we cannot use mStubLock because it isn't supposed to be held long,
    325325  // like in case of an IPC call and such)
    326   PRLock *mStubQILock;
     326  RTSEMFASTMUTEX mStubQILock;
    327327
    328328#if defined(DCONNECT_MULTITHREADED)
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