Skip to content

Commit 0591ddf

Browse files
committed
Refs #21355: Avoid dataraces on RTPS endpoint matching callbacks
Signed-off-by: Carlosespicur <[email protected]>
1 parent e0c453b commit 0591ddf

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

src/cpp/fastdds/subscriber/DataReaderImpl.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ class DataReaderImpl
482482
#endif //FASTDDS_STATISTICS
483483

484484
DataReaderImpl* data_reader_;
485-
486485
}
487486
reader_listener_;
488487

src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,8 @@ bool EDP::unpairWriterProxy(
524524
MatchingInfo info;
525525
info.status = REMOVED_MATCHING;
526526
info.remoteEndpointGuid = writer_guid;
527+
528+
std::lock_guard<RecursiveTimedMutex> lock(r.getMutex());
527529
listener->on_reader_matched(&r, info);
528530
}
529531
}
@@ -559,6 +561,7 @@ bool EDP::unpairReaderProxy(
559561
MatchingInfo info;
560562
info.status = REMOVED_MATCHING;
561563
info.remoteEndpointGuid = reader_guid;
564+
std::lock_guard<RecursiveTimedMutex> lock(w.getMutex());
562565
listener->on_writer_matched(&w, info);
563566
}
564567
}
@@ -868,6 +871,7 @@ bool EDP::pairingReader(
868871
MatchingInfo info;
869872
info.status = MATCHED_MATCHING;
870873
info.remoteEndpointGuid = writer_guid;
874+
std::lock_guard<RecursiveTimedMutex> lock(reader->getMutex());
871875
reader->get_listener()->on_reader_matched(reader, info);
872876
}
873877
}
@@ -896,6 +900,7 @@ bool EDP::pairingReader(
896900
MatchingInfo info;
897901
info.status = REMOVED_MATCHING;
898902
info.remoteEndpointGuid = writer_guid;
903+
std::lock_guard<RecursiveTimedMutex> lock(reader->getMutex());
899904
reader->get_listener()->on_reader_matched(reader, info);
900905
}
901906
}
@@ -961,6 +966,7 @@ bool EDP::pairingWriter(
961966
MatchingInfo info;
962967
info.status = MATCHED_MATCHING;
963968
info.remoteEndpointGuid = reader_guid;
969+
std::lock_guard<RecursiveTimedMutex> lock(writer->getMutex());
964970
writer->get_listener()->on_writer_matched(writer, info);
965971
}
966972
}
@@ -986,6 +992,7 @@ bool EDP::pairingWriter(
986992
MatchingInfo info;
987993
info.status = REMOVED_MATCHING;
988994
info.remoteEndpointGuid = reader_guid;
995+
std::lock_guard<RecursiveTimedMutex> lock(writer->getMutex());
989996
writer->get_listener()->on_writer_matched(writer, info);
990997
}
991998
}
@@ -1037,6 +1044,7 @@ bool EDP::pairing_reader_proxy_with_any_local_writer(
10371044
MatchingInfo info;
10381045
info.status = MATCHED_MATCHING;
10391046
info.remoteEndpointGuid = reader_guid;
1047+
std::lock_guard<RecursiveTimedMutex> lock(w.getMutex());
10401048
w.get_listener()->on_writer_matched(&w, info);
10411049
}
10421050
}
@@ -1063,6 +1071,7 @@ bool EDP::pairing_reader_proxy_with_any_local_writer(
10631071
MatchingInfo info;
10641072
info.status = REMOVED_MATCHING;
10651073
info.remoteEndpointGuid = reader_guid;
1074+
std::lock_guard<RecursiveTimedMutex> lock(w.getMutex());
10661075
w.get_listener()->on_writer_matched(&w, info);
10671076
}
10681077
}
@@ -1130,6 +1139,7 @@ bool EDP::pairing_reader_proxy_with_local_writer(
11301139
MatchingInfo info;
11311140
info.status = REMOVED_MATCHING;
11321141
info.remoteEndpointGuid = reader_guid;
1142+
std::lock_guard<RecursiveTimedMutex> lock(w.getMutex());
11331143
w.get_listener()->on_writer_matched(&w, info);
11341144
}
11351145
}
@@ -1172,6 +1182,7 @@ bool EDP::pairing_remote_reader_with_local_writer_after_security(
11721182
MatchingInfo info;
11731183
info.status = MATCHED_MATCHING;
11741184
info.remoteEndpointGuid = reader_guid;
1185+
std::lock_guard<RecursiveTimedMutex> lock(w.getMutex());
11751186
w.get_listener()->on_writer_matched(&w, info);
11761187
}
11771188
}
@@ -1230,6 +1241,7 @@ bool EDP::pairing_writer_proxy_with_any_local_reader(
12301241
MatchingInfo info;
12311242
info.status = MATCHED_MATCHING;
12321243
info.remoteEndpointGuid = writer_guid;
1244+
std::lock_guard<RecursiveTimedMutex> lock(r.getMutex());
12331245
r.get_listener()->on_reader_matched(&r, info);
12341246
}
12351247
}
@@ -1256,6 +1268,7 @@ bool EDP::pairing_writer_proxy_with_any_local_reader(
12561268
MatchingInfo info;
12571269
info.status = REMOVED_MATCHING;
12581270
info.remoteEndpointGuid = writer_guid;
1271+
std::lock_guard<RecursiveTimedMutex> lock(r.getMutex());
12591272
r.get_listener()->on_reader_matched(&r, info);
12601273
}
12611274
}
@@ -1323,6 +1336,7 @@ bool EDP::pairing_writer_proxy_with_local_reader(
13231336
MatchingInfo info;
13241337
info.status = REMOVED_MATCHING;
13251338
info.remoteEndpointGuid = writer_guid;
1339+
std::lock_guard<RecursiveTimedMutex> lock(r.getMutex());
13261340
r.get_listener()->on_reader_matched(&r, info);
13271341
}
13281342
}
@@ -1367,6 +1381,7 @@ bool EDP::pairing_remote_writer_with_local_reader_after_security(
13671381
MatchingInfo info;
13681382
info.status = MATCHED_MATCHING;
13691383
info.remoteEndpointGuid = writer_guid;
1384+
std::lock_guard<RecursiveTimedMutex> lock(r.getMutex());
13701385
r.get_listener()->on_reader_matched(&r, info);
13711386

13721387
}

test/dds/xtypes/TypeLookupServicePublisher.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ void TypeLookupServicePublisher::on_publication_matched(
305305
DataWriter* /*writer*/,
306306
const PublicationMatchedStatus& info)
307307
{
308-
std::unique_lock<std::mutex> lock(mutex_);
309308
matched_ += info.current_count_change;
310309
cv_.notify_all();
311310
}

test/dds/xtypes/TypeLookupServiceSubscriber.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ void TypeLookupServiceSubscriber::on_subscription_matched(
364364
DataReader* /*reader*/,
365365
const SubscriptionMatchedStatus& info)
366366
{
367-
std::unique_lock<std::mutex> lock(mutex_);
368367
matched_ += info.current_count_change;
369368
cv_.notify_all();
370369
}

0 commit comments

Comments
 (0)