Skip to content

Commit 683e868

Browse files
mergify[bot]Barry-Xu-2018Mario-DLemiliocuestaf
authored
Release change while authentication fails (#5935) (#6022)
* Release change while authentication fails (#5935) * Release change while authentication fails Signed-off-by: Barry Xu <barry.xu@sony.com> * Fix uncrustify error Signed-off-by: Barry Xu <barry.xu@sony.com> * Refs #23431: Refactor PubSubReader/Writer (un)authorized() methods Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com> * Refs #23431: Add regression test Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com> * Refs #23431: Apply Miguel's suggestions Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com> * Refs #23431: Fix windows compilation Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com> * Refs #23431: Uncrustify Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com> * Fix a memory leak on handshake handle Signed-off-by: Barry Xu <barry.xu@sony.com> * Fix an Uncrustify error Signed-off-by: Barry Xu <barry.xu@sony.com> --------- Signed-off-by: Barry Xu <barry.xu@sony.com> Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com> Co-authored-by: Mario Dominguez <mariodominguez@eprosima.com> (cherry picked from commit db64a12) * Fix error in decprecated tests Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com> * Fix backport issues in blackbox tests Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com> * Uncrustify Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com> --------- Signed-off-by: Barry Xu <barry.xu@sony.com> Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com> Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com> Co-authored-by: Barry Xu <barry.xu@sony.com> Co-authored-by: Mario Dominguez <mariodominguez@eprosima.com> Co-authored-by: Emilio Cuesta <emiliocuesta@eprosima.com>
1 parent 6cbdd58 commit 683e868

File tree

9 files changed

+325
-175
lines changed

9 files changed

+325
-175
lines changed

src/cpp/rtps/security/SecurityManager.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4255,6 +4255,19 @@ void SecurityManager::resend_handshake_message_token(
42554255
remote_participant_info->event_->cancel_timer();
42564256
remote_participant_info->auth_status_ = AUTHENTICATION_FAILED;
42574257
on_validation_failed(dp_it->second->participant_data(), exception);
4258+
if (remote_participant_info->change_sequence_number_ != SequenceNumber_t::unknown())
4259+
{
4260+
participant_stateless_message_writer_history_->remove_change(
4261+
remote_participant_info->change_sequence_number_);
4262+
remote_participant_info->change_sequence_number_ = SequenceNumber_t::unknown();
4263+
// Return the handshake handle
4264+
if (remote_participant_info->handshake_handle_ != nullptr)
4265+
{
4266+
authentication_plugin_->return_handshake_handle(
4267+
remote_participant_info->handshake_handle_, exception);
4268+
remote_participant_info->handshake_handle_ = nullptr;
4269+
}
4270+
}
42584271
}
42594272
}
42604273
else

test/blackbox/api/dds-pim/PubSubReader.hpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ class PubSubReader
863863
}
864864

865865
#if HAVE_SECURITY
866-
void waitAuthorized(
866+
void wait_authorized(
867867
std::chrono::seconds timeout = std::chrono::seconds::zero(),
868868
unsigned int expected = 1)
869869
{
@@ -889,16 +889,28 @@ class PubSubReader
889889
std::cout << "Reader authorization finished..." << std::endl;
890890
}
891891

892-
void waitUnauthorized()
892+
void wait_unauthorized(
893+
std::chrono::seconds timeout = std::chrono::seconds::zero(),
894+
unsigned int expected = 1)
893895
{
894896
std::unique_lock<std::mutex> lock(mutexAuthentication_);
895897

896898
std::cout << "Reader is waiting unauthorization..." << std::endl;
897899

898-
cvAuthentication_.wait(lock, [&]() -> bool
899-
{
900-
return unauthorized_ > 0;
901-
});
900+
if (timeout == std::chrono::seconds::zero())
901+
{
902+
cvAuthentication_.wait(lock, [&]()
903+
{
904+
return unauthorized_ >= expected;
905+
});
906+
}
907+
else
908+
{
909+
cvAuthentication_.wait_for(lock, timeout, [&]()
910+
{
911+
return unauthorized_ >= expected;
912+
});
913+
}
902914

903915
std::cout << "Reader unauthorization finished..." << std::endl;
904916
}

test/blackbox/api/dds-pim/PubSubWriter.hpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ class PubSubWriter
739739
}
740740

741741
#if HAVE_SECURITY
742-
void waitAuthorized(
742+
void wait_authorized(
743743
std::chrono::seconds timeout = std::chrono::seconds::zero(),
744744
unsigned int expected = 1)
745745
{
@@ -765,16 +765,28 @@ class PubSubWriter
765765
std::cout << "Writer authorization finished..." << std::endl;
766766
}
767767

768-
void waitUnauthorized()
768+
void wait_unauthorized(
769+
std::chrono::seconds timeout = std::chrono::seconds::zero(),
770+
unsigned int expected = 1)
769771
{
770772
std::unique_lock<std::mutex> lock(mutexAuthentication_);
771773

772774
std::cout << "Writer is waiting unauthorization..." << std::endl;
773775

774-
cvAuthentication_.wait(lock, [&]() -> bool
775-
{
776-
return unauthorized_ > 0;
777-
});
776+
if (timeout == std::chrono::seconds::zero())
777+
{
778+
cvAuthentication_.wait(lock, [&]()
779+
{
780+
return unauthorized_ >= expected;
781+
});
782+
}
783+
else
784+
{
785+
cvAuthentication_.wait_for(lock, timeout, [&]()
786+
{
787+
return unauthorized_ >= expected;
788+
});
789+
}
778790

779791
std::cout << "Writer unauthorization finished..." << std::endl;
780792
}

test/blackbox/api/dds-pim/PubSubWriterReader.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ class PubSubWriterReader
683683
}
684684

685685
#if HAVE_SECURITY
686-
void waitAuthorized(
686+
void wait_authorized(
687687
unsigned int how_many = 1)
688688
{
689689
std::unique_lock<std::mutex> lock(mutexAuthentication_);
@@ -699,7 +699,7 @@ class PubSubWriterReader
699699
std::cout << "WReader authorization finished..." << std::endl;
700700
}
701701

702-
void waitUnauthorized(
702+
void wait_unauthorized(
703703
unsigned int how_many = 1)
704704
{
705705
std::unique_lock<std::mutex> lock(mutexAuthentication_);

test/blackbox/api/fastrtps_deprecated/PubSubReader.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ class PubSubReader
608608
}
609609

610610
#if HAVE_SECURITY
611-
void waitAuthorized(
611+
void wait_authorized(
612612
std::chrono::seconds timeout = std::chrono::seconds::zero(),
613613
unsigned int expected = 1)
614614
{
@@ -634,7 +634,7 @@ class PubSubReader
634634
std::cout << "Reader authorization finished..." << std::endl;
635635
}
636636

637-
void waitUnauthorized()
637+
void wait_unauthorized()
638638
{
639639
std::unique_lock<std::mutex> lock(mutexAuthentication_);
640640

test/blackbox/api/fastrtps_deprecated/PubSubWriter.hpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ class PubSubWriter
571571
}
572572

573573
#if HAVE_SECURITY
574-
void waitAuthorized(
574+
void wait_authorized(
575575
std::chrono::seconds timeout = std::chrono::seconds::zero(),
576576
unsigned int expected = 1)
577577
{
@@ -597,16 +597,28 @@ class PubSubWriter
597597
std::cout << "Writer authorization finished..." << std::endl;
598598
}
599599

600-
void waitUnauthorized()
600+
void wait_unauthorized(
601+
std::chrono::seconds timeout = std::chrono::seconds::zero(),
602+
unsigned int expected = 1)
601603
{
602604
std::unique_lock<std::mutex> lock(mutexAuthentication_);
603605

604606
std::cout << "Writer is waiting unauthorization..." << std::endl;
605607

606-
cvAuthentication_.wait(lock, [&]() -> bool
607-
{
608-
return unauthorized_ > 0;
609-
});
608+
if (timeout == std::chrono::seconds::zero())
609+
{
610+
cvAuthentication_.wait(lock, [&]() -> bool
611+
{
612+
return unauthorized_ >= expected;
613+
});
614+
}
615+
else
616+
{
617+
cvAuthentication_.wait_for(lock, timeout, [&]() -> bool
618+
{
619+
return unauthorized_ >= expected;
620+
});
621+
}
610622

611623
std::cout << "Writer unauthorization finished..." << std::endl;
612624
}

test/blackbox/api/fastrtps_deprecated/PubSubWriterReader.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ class PubSubWriterReader
534534
}
535535

536536
#if HAVE_SECURITY
537-
void waitAuthorized(
537+
void wait_authorized(
538538
unsigned int how_many = 1)
539539
{
540540
std::unique_lock<std::mutex> lock(mutexAuthentication_);
@@ -550,7 +550,7 @@ class PubSubWriterReader
550550
std::cout << "WReader authorization finished..." << std::endl;
551551
}
552552

553-
void waitUnauthorized(
553+
void wait_unauthorized(
554554
unsigned int how_many = 1)
555555
{
556556
std::unique_lock<std::mutex> lock(mutexAuthentication_);

0 commit comments

Comments
 (0)