mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 17:41:45 +00:00
Avoid deadlock in FairMQChannel operator=, handle self-assignment
This commit is contained in:
committed by
Dennis Klein
parent
692ec4e997
commit
383e307f50
@@ -133,9 +133,15 @@ FairMQChannel::FairMQChannel(const FairMQChannel& chan, const string& newName)
|
||||
|
||||
FairMQChannel& FairMQChannel::operator=(const FairMQChannel& chan)
|
||||
{
|
||||
if (this == &chan) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock1(fMtx);
|
||||
lock_guard<mutex> lock2(chan.fMtx);
|
||||
// TODO: replace this with std::scoped_lock (c++17)
|
||||
lock(fMtx, chan.fMtx);
|
||||
lock_guard<mutex> lock1(fMtx, adopt_lock);
|
||||
lock_guard<mutex> lock2(chan.fMtx, adopt_lock);
|
||||
|
||||
fTransportFactory = nullptr;
|
||||
fTransportType = chan.fTransportType;
|
||||
|
Reference in New Issue
Block a user