@@ -1218,55 +1218,58 @@ bool StatefulWriter::matched_reader_remove(
1218
1218
{
1219
1219
ReaderProxy* rproxy = nullptr ;
1220
1220
std::unique_lock<RecursiveTimedMutex> lock (mp_mutex);
1221
- std::unique_lock<LocatorSelectorSender> guard_locator_selector_general (locator_selector_general_);
1222
- std::unique_lock<LocatorSelectorSender> guard_locator_selector_async (locator_selector_async_);
1223
1221
1224
- for (ReaderProxyIterator it = matched_local_readers_.begin ();
1225
- it != matched_local_readers_.end (); ++it)
1226
1222
{
1227
- if ((*it)->guid () == reader_guid)
1228
- {
1229
- EPROSIMA_LOG_INFO (RTPS_WRITER, " Reader Proxy removed: " << reader_guid);
1230
- rproxy = std::move (*it);
1231
- it = matched_local_readers_.erase (it);
1232
- break ;
1233
- }
1234
- }
1223
+ std::lock_guard<LocatorSelectorSender> guard_locator_selector_general (locator_selector_general_);
1224
+ std::lock_guard<LocatorSelectorSender> guard_locator_selector_async (locator_selector_async_);
1235
1225
1236
- if (rproxy == nullptr )
1237
- {
1238
- for (ReaderProxyIterator it = matched_datasharing_readers_.begin ();
1239
- it != matched_datasharing_readers_.end (); ++it)
1226
+ for (ReaderProxyIterator it = matched_local_readers_.begin ();
1227
+ it != matched_local_readers_.end (); ++it)
1240
1228
{
1241
1229
if ((*it)->guid () == reader_guid)
1242
1230
{
1243
1231
EPROSIMA_LOG_INFO (RTPS_WRITER, " Reader Proxy removed: " << reader_guid);
1244
1232
rproxy = std::move (*it);
1245
- it = matched_datasharing_readers_ .erase (it);
1233
+ it = matched_local_readers_ .erase (it);
1246
1234
break ;
1247
1235
}
1248
1236
}
1249
- }
1250
1237
1251
- if (rproxy == nullptr )
1252
- {
1253
- for (ReaderProxyIterator it = matched_remote_readers_.begin ();
1254
- it != matched_remote_readers_.end (); ++it)
1238
+ if (rproxy == nullptr )
1255
1239
{
1256
- if ((*it)->guid () == reader_guid)
1240
+ for (ReaderProxyIterator it = matched_datasharing_readers_.begin ();
1241
+ it != matched_datasharing_readers_.end (); ++it)
1257
1242
{
1258
- EPROSIMA_LOG_INFO (RTPS_WRITER, " Reader Proxy removed: " << reader_guid);
1259
- rproxy = std::move (*it);
1260
- it = matched_remote_readers_.erase (it);
1261
- break ;
1243
+ if ((*it)->guid () == reader_guid)
1244
+ {
1245
+ EPROSIMA_LOG_INFO (RTPS_WRITER, " Reader Proxy removed: " << reader_guid);
1246
+ rproxy = std::move (*it);
1247
+ it = matched_datasharing_readers_.erase (it);
1248
+ break ;
1249
+ }
1262
1250
}
1263
1251
}
1264
- }
1265
1252
1266
- locator_selector_general_.locator_selector .remove_entry (reader_guid);
1267
- locator_selector_async_.locator_selector .remove_entry (reader_guid);
1268
- update_reader_info (locator_selector_general_, false );
1269
- update_reader_info (locator_selector_async_, false );
1253
+ if (rproxy == nullptr )
1254
+ {
1255
+ for (ReaderProxyIterator it = matched_remote_readers_.begin ();
1256
+ it != matched_remote_readers_.end (); ++it)
1257
+ {
1258
+ if ((*it)->guid () == reader_guid)
1259
+ {
1260
+ EPROSIMA_LOG_INFO (RTPS_WRITER, " Reader Proxy removed: " << reader_guid);
1261
+ rproxy = std::move (*it);
1262
+ it = matched_remote_readers_.erase (it);
1263
+ break ;
1264
+ }
1265
+ }
1266
+ }
1267
+
1268
+ locator_selector_general_.locator_selector .remove_entry (reader_guid);
1269
+ locator_selector_async_.locator_selector .remove_entry (reader_guid);
1270
+ update_reader_info (locator_selector_general_, false );
1271
+ update_reader_info (locator_selector_async_, false );
1272
+ }
1270
1273
1271
1274
if (get_matched_readers_size () == 0 )
1272
1275
{
@@ -1282,11 +1285,8 @@ bool StatefulWriter::matched_reader_remove(
1282
1285
1283
1286
if (nullptr != listener_)
1284
1287
{
1285
- // call the listener without locks taken
1286
- guard_locator_selector_async.unlock ();
1287
- guard_locator_selector_general.unlock ();
1288
+ // listener is called without locks taken
1288
1289
lock.unlock ();
1289
-
1290
1290
listener_->on_reader_discovery (this , ReaderDiscoveryStatus::REMOVED_READER, reader_guid, nullptr );
1291
1291
}
1292
1292
0 commit comments