Skip to content

Commit 5fd8c47

Browse files
Fix locking (syntax whoops)
1 parent b3e9ebc commit 5fd8c47

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/Driver.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void freeUnusedChannelBuffers()
3636
{
3737
namespace bfs = boost::filesystem;
3838
InfoLogger::InfoLogger logger;
39-
Pda::PdaLock lock(); // We're messing around with PDA buffers so we need this
39+
Pda::PdaLock lock{}; // We're messing around with PDA buffers so we need this
4040

4141
try {
4242
std::string pciPath = "/sys/bus/pci/drivers/uio_pci_dma/";

src/Pda/PdaDmaBuffer.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ PdaDmaBuffer::PdaDmaBuffer(PdaDevice::PdaPciDevice pciDevice, void* userBufferAd
1818
int dmaBufferId, bool requireHugepage) : mPciDevice(pciDevice)
1919
{
2020
// Safeguard against PDA kernel module deadlocks, since it does not like parallel buffer registration
21-
PdaLock lock();
21+
Pda::PdaLock lock{};
2222

2323
try {
2424
// Tell PDA we're using our already allocated userspace buffer.
@@ -100,7 +100,7 @@ PdaDmaBuffer::~PdaDmaBuffer()
100100
// Safeguard against PDA kernel module deadlocks, since it does not like parallel buffer registration
101101
// NOTE: not sure if necessary for deregistration as well
102102
try {
103-
PdaLock lock();
103+
Pda::PdaLock lock{};
104104
PciDevice_deleteDMABuffer(mPciDevice.get(), mDmaBuffer);
105105
} catch (std::exception& e) {
106106
// Nothing to be done?

src/Pda/PdaLock.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@ namespace Pda {
1717
/// Just hope nobody else uses PDA in parallel.
1818
class PdaLock
1919
{
20-
PdaLock() : mLock("/dev/shm/alice_o2/rorc/AliceO2_roc_Pda_PdaDmaBuffer.lock", "AliceO2_roc_Pda_PdaDmaBuffer_Mutex",
21-
true)
20+
public:
21+
22+
/// Be careful you don't use it like this:
23+
/// Pda::PdaLock lock()
24+
/// But rather like this:
25+
/// Pda::PdaLock lock{}
26+
PdaLock(bool wait = true) : mLock("/dev/shm/alice_o2/rorc/AliceO2_roc_Pda_PdaDmaBuffer.lock",
27+
"AliceO2_roc_Pda_PdaDmaBuffer_Mutex", wait)
2228
{
2329
}
2430

0 commit comments

Comments
 (0)