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