ATLAS Offline Software
DsoRootLock.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
12 #include "CxxUtils/AthDsoCbk.h"
14 #include "TVirtualRWMutex.h"
15 
16 
36 {
37 public:
41  DsoRootLock();
42 
43 
47  static int hook (const ath_dso_event* event, void* userdata);
48 };
49 
50 
55 {
56  ath_dso_cbk_register (hook, nullptr);
57 }
58 
59 
63 int DsoRootLock::hook (const ath_dso_event* event, void* /*userdata*/)
64 {
65  // Skip for Xrd libraries --- otherwise we can deadlock.
66  if (event->fname && strncmp (event->fname, "libXrd", 6) == 0) return 0;
67 
68  // If the core mutex has been created, acquire it before loading
69  // a library and release it on completion.
70  // Hope these are always properly nested!
71  ROOT::TVirtualRWMutex* m ATLAS_THREAD_SAFE = ROOT::gCoreMutex;
72  if (m) {
73  if (event->step == 0) {
74  m->WriteLock();
75  }
76  else if (event->step == 1)
77  {
78  m->WriteUnLock(nullptr);
79  }
80  }
81  return 0;
82 }
83 
84 
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
DsoRootLock::DsoRootLock
DsoRootLock()
Constructor.
Definition: DsoRootLock.cxx:54
DsoRootLock::hook
static int hook(const ath_dso_event *event, void *userdata)
Acquire the ROOT core lock during library loading.
Definition: DsoRootLock.cxx:63
dsoRootLock
const DsoRootLock dsoRootLock
Set up this hook when this library gets loaded.
Definition: DsoRootLock.cxx:86
AthDsoCbk.h
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
ath_dso_cbk_register
int ath_dso_cbk_register(ath_dso_event_cbk_t cbk, void *userdata)
ath_dso_event
-*- C -*- AthDsoCbk.h Header file for the dso callbacks api Author: S.Binetbinet@cern....
Definition: AthDsoCbk.h:22
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
DsoRootLock
Workaround for ROOT TClassTable locking problem.
Definition: DsoRootLock.cxx:36
checker_macros.h
Define macros for attributes used to control the static checker.