@@ -1266,55 +1266,58 @@ bool StatefulWriter::matched_reader_remove(
1266
1266
{
1267
1267
ReaderProxy* rproxy = nullptr ;
1268
1268
std::unique_lock<RecursiveTimedMutex> lock (mp_mutex);
1269
- std::unique_lock<LocatorSelectorSender> guard_locator_selector_general (locator_selector_general_);
1270
- std::unique_lock<LocatorSelectorSender> guard_locator_selector_async (locator_selector_async_);
1271
1269
1272
- for (ReaderProxyIterator it = matched_local_readers_.begin ();
1273
- it != matched_local_readers_.end (); ++it)
1274
1270
{
1275
- if ((*it)->guid () == reader_guid)
1276
- {
1277
- EPROSIMA_LOG_INFO (RTPS_WRITER, " Reader Proxy removed: " << reader_guid);
1278
- rproxy = std::move (*it);
1279
- it = matched_local_readers_.erase (it);
1280
- break ;
1281
- }
1282
- }
1271
+ std::lock_guard<LocatorSelectorSender> guard_locator_selector_general (locator_selector_general_);
1272
+ std::lock_guard<LocatorSelectorSender> guard_locator_selector_async (locator_selector_async_);
1283
1273
1284
- if (rproxy == nullptr )
1285
- {
1286
- for (ReaderProxyIterator it = matched_datasharing_readers_.begin ();
1287
- it != matched_datasharing_readers_.end (); ++it)
1274
+ for (ReaderProxyIterator it = matched_local_readers_.begin ();
1275
+ it != matched_local_readers_.end (); ++it)
1288
1276
{
1289
1277
if ((*it)->guid () == reader_guid)
1290
1278
{
1291
1279
EPROSIMA_LOG_INFO (RTPS_WRITER, " Reader Proxy removed: " << reader_guid);
1292
1280
rproxy = std::move (*it);
1293
- it = matched_datasharing_readers_ .erase (it);
1281
+ it = matched_local_readers_ .erase (it);
1294
1282
break ;
1295
1283
}
1296
1284
}
1297
- }
1298
1285
1299
- if (rproxy == nullptr )
1300
- {
1301
- for (ReaderProxyIterator it = matched_remote_readers_.begin ();
1302
- it != matched_remote_readers_.end (); ++it)
1286
+ if (rproxy == nullptr )
1303
1287
{
1304
- if ((*it)->guid () == reader_guid)
1288
+ for (ReaderProxyIterator it = matched_datasharing_readers_.begin ();
1289
+ it != matched_datasharing_readers_.end (); ++it)
1305
1290
{
1306
- EPROSIMA_LOG_INFO (RTPS_WRITER, " Reader Proxy removed: " << reader_guid);
1307
- rproxy = std::move (*it);
1308
- it = matched_remote_readers_.erase (it);
1309
- break ;
1291
+ if ((*it)->guid () == reader_guid)
1292
+ {
1293
+ EPROSIMA_LOG_INFO (RTPS_WRITER, " Reader Proxy removed: " << reader_guid);
1294
+ rproxy = std::move (*it);
1295
+ it = matched_datasharing_readers_.erase (it);
1296
+ break ;
1297
+ }
1310
1298
}
1311
1299
}
1312
- }
1313
1300
1314
- locator_selector_general_.locator_selector .remove_entry (reader_guid);
1315
- locator_selector_async_.locator_selector .remove_entry (reader_guid);
1316
- update_reader_info (locator_selector_general_, false );
1317
- update_reader_info (locator_selector_async_, false );
1301
+ if (rproxy == nullptr )
1302
+ {
1303
+ for (ReaderProxyIterator it = matched_remote_readers_.begin ();
1304
+ it != matched_remote_readers_.end (); ++it)
1305
+ {
1306
+ if ((*it)->guid () == reader_guid)
1307
+ {
1308
+ EPROSIMA_LOG_INFO (RTPS_WRITER, " Reader Proxy removed: " << reader_guid);
1309
+ rproxy = std::move (*it);
1310
+ it = matched_remote_readers_.erase (it);
1311
+ break ;
1312
+ }
1313
+ }
1314
+ }
1315
+
1316
+ locator_selector_general_.locator_selector .remove_entry (reader_guid);
1317
+ locator_selector_async_.locator_selector .remove_entry (reader_guid);
1318
+ update_reader_info (locator_selector_general_, false );
1319
+ update_reader_info (locator_selector_async_, false );
1320
+ }
1318
1321
1319
1322
if (getMatchedReadersSize () == 0 )
1320
1323
{
@@ -1330,11 +1333,8 @@ bool StatefulWriter::matched_reader_remove(
1330
1333
1331
1334
if (nullptr != mp_listener)
1332
1335
{
1333
- // call the listener without locks taken
1334
- guard_locator_selector_async.unlock ();
1335
- guard_locator_selector_general.unlock ();
1336
+ // listener is called without locks taken
1336
1337
lock.unlock ();
1337
-
1338
1338
mp_listener->on_reader_discovery (this , ReaderDiscoveryInfo::REMOVED_READER, reader_guid, nullptr );
1339
1339
}
1340
1340
0 commit comments