@@ -373,7 +373,7 @@ bool PDP::initPDP(
373
373
mp_builtin->updateMetatrafficLocators (this ->mp_PDPReader ->getAttributes ().unicastLocatorList );
374
374
375
375
mp_mutex->lock ();
376
- ParticipantProxyData* pdata = add_participant_proxy_data (part ->getGuid (), false );
376
+ ParticipantProxyData* pdata = add_participant_proxy_data (mp_RTPSParticipant ->getGuid (), false );
377
377
mp_mutex->unlock ();
378
378
379
379
if (pdata == nullptr )
@@ -382,6 +382,11 @@ bool PDP::initPDP(
382
382
}
383
383
initializeParticipantProxyData (pdata);
384
384
385
+ return true ;
386
+ }
387
+
388
+ bool PDP::enable ()
389
+ {
385
390
// Create lease events on already created proxy data objects
386
391
for (ParticipantProxyData* pool_item : participant_proxies_pool_)
387
392
{
@@ -404,11 +409,8 @@ bool PDP::initPDP(
404
409
405
410
set_initial_announcement_interval ();
406
411
407
- return true ;
408
- }
412
+ enable_ = true ;
409
413
410
- bool PDP::enable ()
411
- {
412
414
return mp_RTPSParticipant->enableReader (mp_PDPReader);
413
415
}
414
416
@@ -417,30 +419,75 @@ void PDP::announceParticipantState(
417
419
bool dispose,
418
420
WriteParams& wparams)
419
421
{
420
- // logInfo(RTPS_PDP, "Announcing RTPSParticipant State (new change: " << new_change << ")");
421
- CacheChange_t* change = nullptr ;
422
-
423
- if (!dispose)
422
+ if (enable_)
424
423
{
425
- if (m_hasChangedLocalPDP.exchange (false ) || new_change)
424
+ // logInfo(RTPS_PDP, "Announcing RTPSParticipant State (new change: " << new_change << ")");
425
+ CacheChange_t* change = nullptr ;
426
+
427
+ if (!dispose)
428
+ {
429
+ if (m_hasChangedLocalPDP.exchange (false ) || new_change)
430
+ {
431
+ this ->mp_mutex ->lock ();
432
+ ParticipantProxyData* local_participant_data = getLocalParticipantProxyData ();
433
+ InstanceHandle_t key = local_participant_data->m_key ;
434
+ ParticipantProxyData proxy_data_copy (*local_participant_data);
435
+ this ->mp_mutex ->unlock ();
436
+
437
+ if (mp_PDPWriterHistory->getHistorySize () > 0 )
438
+ {
439
+ mp_PDPWriterHistory->remove_min_change ();
440
+ }
441
+ uint32_t cdr_size = proxy_data_copy.get_serialized_size (true );
442
+ change = mp_PDPWriter->new_change (
443
+ [cdr_size]() -> uint32_t
444
+ {
445
+ return cdr_size;
446
+ },
447
+ ALIVE, key);
448
+
449
+ if (change != nullptr )
450
+ {
451
+ CDRMessage_t aux_msg (change->serializedPayload );
452
+
453
+ #if __BIG_ENDIAN__
454
+ change->serializedPayload .encapsulation = (uint16_t )PL_CDR_BE;
455
+ aux_msg.msg_endian = BIGEND;
456
+ #else
457
+ change->serializedPayload .encapsulation = (uint16_t )PL_CDR_LE;
458
+ aux_msg.msg_endian = LITTLEEND;
459
+ #endif // if __BIG_ENDIAN__
460
+
461
+ if (proxy_data_copy.writeToCDRMessage (&aux_msg, true ))
462
+ {
463
+ change->serializedPayload .length = (uint16_t )aux_msg.length ;
464
+
465
+ mp_PDPWriterHistory->add_change (change, wparams);
466
+ }
467
+ else
468
+ {
469
+ logError (RTPS_PDP, " Cannot serialize ParticipantProxyData." );
470
+ }
471
+ }
472
+ }
473
+
474
+ }
475
+ else
426
476
{
427
477
this ->mp_mutex ->lock ();
428
- ParticipantProxyData* local_participant_data = getLocalParticipantProxyData ();
429
- InstanceHandle_t key = local_participant_data->m_key ;
430
- ParticipantProxyData proxy_data_copy (*local_participant_data);
478
+ ParticipantProxyData proxy_data_copy (*getLocalParticipantProxyData ());
431
479
this ->mp_mutex ->unlock ();
432
480
433
481
if (mp_PDPWriterHistory->getHistorySize () > 0 )
434
482
{
435
483
mp_PDPWriterHistory->remove_min_change ();
436
484
}
437
485
uint32_t cdr_size = proxy_data_copy.get_serialized_size (true );
438
- change = mp_PDPWriter->new_change (
439
- [cdr_size]() -> uint32_t
440
- {
441
- return cdr_size;
442
- },
443
- ALIVE, key);
486
+ change = mp_PDPWriter->new_change ([cdr_size]() -> uint32_t
487
+ {
488
+ return cdr_size;
489
+ },
490
+ NOT_ALIVE_DISPOSED_UNREGISTERED, getLocalParticipantProxyData ()->m_key );
444
491
445
492
if (change != nullptr )
446
493
{
@@ -466,48 +513,6 @@ void PDP::announceParticipantState(
466
513
}
467
514
}
468
515
}
469
-
470
- }
471
- else
472
- {
473
- this ->mp_mutex ->lock ();
474
- ParticipantProxyData proxy_data_copy (*getLocalParticipantProxyData ());
475
- this ->mp_mutex ->unlock ();
476
-
477
- if (mp_PDPWriterHistory->getHistorySize () > 0 )
478
- {
479
- mp_PDPWriterHistory->remove_min_change ();
480
- }
481
- uint32_t cdr_size = proxy_data_copy.get_serialized_size (true );
482
- change = mp_PDPWriter->new_change ([cdr_size]() -> uint32_t
483
- {
484
- return cdr_size;
485
- },
486
- NOT_ALIVE_DISPOSED_UNREGISTERED, getLocalParticipantProxyData ()->m_key );
487
-
488
- if (change != nullptr )
489
- {
490
- CDRMessage_t aux_msg (change->serializedPayload );
491
-
492
- #if __BIG_ENDIAN__
493
- change->serializedPayload .encapsulation = (uint16_t )PL_CDR_BE;
494
- aux_msg.msg_endian = BIGEND;
495
- #else
496
- change->serializedPayload .encapsulation = (uint16_t )PL_CDR_LE;
497
- aux_msg.msg_endian = LITTLEEND;
498
- #endif // if __BIG_ENDIAN__
499
-
500
- if (proxy_data_copy.writeToCDRMessage (&aux_msg, true ))
501
- {
502
- change->serializedPayload .length = (uint16_t )aux_msg.length ;
503
-
504
- mp_PDPWriterHistory->add_change (change, wparams);
505
- }
506
- else
507
- {
508
- logError (RTPS_PDP, " Cannot serialize ParticipantProxyData." );
509
- }
510
- }
511
516
}
512
517
513
518
}
0 commit comments