VirtualBox

Changeset 101976 in vbox for trunk/src/libs/xpcom18a4


Ignore:
Timestamp:
Nov 8, 2023 1:38:41 PM (15 months ago)
Author:
vboxsync
Message:

libs/xpcom/xpcom/components: Convert some code from using PRLock to IPRT's RTSEMFASTMUTEX locks, bugref:10545

Location:
trunk/src/libs/xpcom18a4/xpcom/components
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/xpcom/components/nsCategoryManager.cpp

    r1 r101976  
    5858#include "nsEnumeratorUtils.h"
    5959
     60#include <iprt/assert.h>
     61#include <iprt/errcore.h>
     62
    6063class nsIComponentLoaderManager;
    6164
     
    216219  }
    217220
    218   node->mLock = PR_NewLock();
    219   if (!node->mLock) {
     221  node->mLock = NIL_RTSEMFASTMUTEX;
     222  int vrc = RTSemFastMutexCreate(&node->mLock);
     223  if (RT_FAILURE(vrc)) {
    220224    delete node;
    221225    return nsnull;
     
    227231CategoryNode::~CategoryNode()
    228232{
    229   if (mLock)
    230     PR_DestroyLock(mLock);
     233  if (mLock != NIL_RTSEMFASTMUTEX)
     234  {
     235    RTSemFastMutexDestroy(mLock);
     236    mLock = NIL_RTSEMFASTMUTEX;
     237  }
    231238}
    232239
     
    243250                      char** _retval)
    244251{
    245   PR_Lock(mLock);
     252  RTSemFastMutexRequest(mLock);
    246253  nsresult rv = NS_ERROR_NOT_AVAILABLE;
    247254  CategoryLeaf* ent =
     
    254261      rv = NS_OK;
    255262  }
    256   PR_Unlock(mLock);
     263  RTSemFastMutexRelease(mLock);
    257264
    258265  return rv;
     
    267274                      PLArenaPool* aArena)
    268275{
    269   PR_Lock(mLock);
     276  RTSemFastMutexRequest(mLock);
    270277  CategoryLeaf* leaf =
    271278    mTable.GetEntry(aEntryName);
     
    298305  }
    299306   
    300   PR_Unlock(mLock);
     307  RTSemFastMutexRelease(mLock);
    301308  return rv;
    302309}
     
    308315  // we don't throw any errors, because it normally doesn't matter
    309316  // and it makes JS a lot cleaner
    310   PR_Lock(mLock);
     317  RTSemFastMutexRequest(mLock);
    311318
    312319  if (aDontPersist) {
     
    326333    }
    327334  }
    328   PR_Unlock(mLock);
     335  RTSemFastMutexRelease(mLock);
    329336
    330337  return NS_OK;
     
    336343  NS_ENSURE_ARG_POINTER(_retval);
    337344
    338   PR_Lock(mLock);
     345  RTSemFastMutexRequest(mLock);
    339346  EntryEnumerator* enumObj = EntryEnumerator::Create(mTable);
    340   PR_Unlock(mLock);
     347  RTSemFastMutexRelease(mLock);
    341348
    342349  if (!enumObj)
     
    385392  };
    386393
    387   PR_Lock(mLock);
     394  RTSemFastMutexRequest(mLock);
    388395  mTable.EnumerateEntries(enumfunc_pentries, &args);
    389   PR_Unlock(mLock);
     396  RTSemFastMutexRelease(mLock);
    390397
    391398  return args.success;
     
    463470  }
    464471
    465   manager->mLock = PR_NewLock();
    466 
    467   if (!manager->mLock) {
     472  manager->mLock = NIL_RTSEMFASTMUTEX;
     473  int vrc = RTSemFastMutexCreate(&manager->mLock);
     474  if (RT_FAILURE(vrc))
     475  {
    468476    delete manager;
    469477    return nsnull;
     
    475483nsCategoryManager::~nsCategoryManager()
    476484{
    477   if (mLock)
    478     PR_DestroyLock(mLock);
     485  if (mLock != NIL_RTSEMFASTMUTEX)
     486  {
     487    RTSemFastMutexDestroy(mLock);
     488    mLock = NIL_RTSEMFASTMUTEX;
     489  }
    479490
    480491  // the hashtable contains entries that must be deleted before the arena is
     
    506517  nsresult status = NS_ERROR_NOT_AVAILABLE;
    507518
    508   PR_Lock(mLock);
     519  RTSemFastMutexRequest(mLock);
    509520  CategoryNode* category = get_category(aCategoryName);
    510   PR_Unlock(mLock);
     521  RTSemFastMutexRelease(mLock);
    511522
    512523  if (category) {
     
    531542  // Before we can insert a new entry, we'll need to
    532543  //  find the |CategoryNode| to put it in...
    533   PR_Lock(mLock);
     544  RTSemFastMutexRequest(mLock);
    534545  CategoryNode* category = get_category(aCategoryName);
    535546
     
    541552    mTable.Put(categoryName, category);
    542553  }
    543   PR_Unlock(mLock);
     554  RTSemFastMutexRelease(mLock);
    544555
    545556  if (!category)
     
    568579  */
    569580
    570   PR_Lock(mLock);
     581  RTSemFastMutexRequest(mLock);
    571582  CategoryNode* category = get_category(aCategoryName);
    572   PR_Unlock(mLock);
     583  RTSemFastMutexRelease(mLock);
    573584
    574585  if (!category)
     
    588599  // leaf nodes.
    589600
    590   PR_Lock(mLock);
     601  RTSemFastMutexRequest(mLock);
    591602  CategoryNode* category = get_category(aCategoryName);
    592   PR_Unlock(mLock);
     603  RTSemFastMutexRelease(mLock);
    593604
    594605  if (category)
     
    605616  NS_ENSURE_ARG_POINTER(_retval);
    606617
    607   PR_Lock(mLock);
     618  RTSemFastMutexRequest(mLock);
    608619  CategoryNode* category = get_category(aCategoryName);
    609   PR_Unlock(mLock);
     620  RTSemFastMutexRelease(mLock);
    610621 
    611622  if (!category) {
     
    621632  NS_ENSURE_ARG_POINTER(_retval);
    622633
    623   PR_Lock(mLock);
     634  RTSemFastMutexRequest(mLock);
    624635  CategoryEnumerator* enumObj = CategoryEnumerator::Create(mTable);
    625   PR_Unlock(mLock);
     636  RTSemFastMutexRelease(mLock);
    626637
    627638  if (!enumObj)
     
    661672  };
    662673
    663   PR_Lock(mLock);
     674  RTSemFastMutexRequest(mLock);
    664675  mTable.EnumerateRead(enumfunc_categories, &args);
    665   PR_Unlock(mLock);
     676  RTSemFastMutexRelease(mLock);
    666677
    667678  if (!args.success) {
  • trunk/src/libs/xpcom18a4/xpcom/components/nsCategoryManager.h

    r62333 r101976  
    4141
    4242#include "prio.h"
    43 #include "prlock.h"
    4443#include "plarena.h"
    4544#include "nsClassHashtable.h"
    4645#include "nsICategoryManager.h"
     46
     47#include <iprt/semaphore.h>
    4748
    4849#define NS_CATEGORYMANAGER_CLASSNAME     "Category Manager"
     
    9596
    9697  void Clear() {
    97     PR_Lock(mLock);
     98    RTSemFastMutexRequest(mLock);
    9899    mTable.Clear();
    99     PR_Unlock(mLock);
     100    RTSemFastMutexRelease(mLock);
    100101  }
    101102
    102103  PRUint32 Count() {
    103     PR_Lock(mLock);
     104    RTSemFastMutexRequest(mLock);
    104105    PRUint32 tCount = mTable.Count();
    105     PR_Unlock(mLock);
     106    RTSemFastMutexRelease(mLock);
    106107    return tCount;
    107108  }
     
    121122
    122123  nsTHashtable<CategoryLeaf> mTable;
    123   PRLock* mLock;
     124  RTSEMFASTMUTEX mLock;
    124125};
    125126
     
    154155  PLArenaPool mArena;
    155156  nsClassHashtable<nsDepCharHashKey, CategoryNode> mTable;
    156   PRLock* mLock;
     157  RTSEMFASTMUTEX mLock;
    157158};
    158159
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