Skip to content

Commit

Permalink
[XrdCrypto] Avoid race in GetCryptoFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
smithdh authored and amadio committed Jul 10, 2023
1 parent 496a044 commit 2f2206c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/XrdCrypto/XrdCryptoFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "XrdOuc/XrdOucHash.hh"
#include "XrdOuc/XrdOucPinLoader.hh"
#include "XrdSys/XrdSysPlatform.hh"
#include "XrdSys/XrdSysPthread.hh"

#include "XrdVersion.hh"

Expand Down Expand Up @@ -418,6 +419,7 @@ XrdCryptoFactory *XrdCryptoFactory::GetCryptoFactory(const char *factoryid)
// Static method to load/locate the crypto factory named factoryid

static XrdVERSIONINFODEF(myVer,cryptoloader,XrdVNUMBER,XrdVERSION);
static XrdSysMutex fMutex;
static FactoryEntry *factorylist = 0;
static int factorynum = 0;
static XrdOucHash<XrdOucPinLoader> plugins;
Expand All @@ -426,6 +428,10 @@ XrdCryptoFactory *XrdCryptoFactory::GetCryptoFactory(const char *factoryid)
char factobjname[80], libfn[80];
EPNAME("Factory::GetCryptoFactory");

// Factory entries are tracked in a static list.
// Make sure only one thread may be using or modifying the list at a time.
XrdSysMutexHelper mHelp(fMutex);

//
// The id must be defined
if (!factoryid) {
Expand Down

0 comments on commit 2f2206c

Please sign in to comment.