-
Notifications
You must be signed in to change notification settings - Fork 191
Fix[mqbnet::InitialConnectionContext]: propagate close to authn #1639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,13 +100,15 @@ bool AuthenticationState::fromAscii(AuthenticationState::Enum* out, | |
| // --------------------------- | ||
|
|
||
| AuthenticationContext::AuthenticationContext( | ||
| bdlmt::EventScheduler* scheduler, | ||
| InitialConnectionContext* initialConnectionContext, | ||
| bsl::string_view mechanism, | ||
| const bmqp_ctrlmsg::AuthenticationMessage& authenticationMessage, | ||
| bmqp::EncodingType::Enum authenticationEncodingType, | ||
| AuthenticationState::Enum state, | ||
| bslma::Allocator* allocator) | ||
| : d_allocator_p(allocator) | ||
| , d_scheduler_p(scheduler) | ||
| , d_self(this) // use default allocator | ||
| , d_mutex() | ||
| , d_authenticationResultSp() | ||
|
|
@@ -117,7 +119,8 @@ AuthenticationContext::AuthenticationContext( | |
| , d_authenticationMessage(authenticationMessage) | ||
| , d_encodingType(authenticationEncodingType) | ||
| { | ||
| // NOTHING | ||
| // PRECONDITION | ||
| BSLS_ASSERT_SAFE(d_scheduler_p); | ||
| } | ||
|
|
||
| void AuthenticationContext::setAuthenticationResult( | ||
|
|
@@ -153,14 +156,12 @@ void AuthenticationContext::resetAuthenticationMessage() | |
|
|
||
| int AuthenticationContext::setAuthenticatedAndScheduleReauthn( | ||
| bsl::ostream& errorDescription, | ||
| bdlmt::EventScheduler* scheduler_p, | ||
| const bsl::optional<bsls::Types::Uint64>& lifetimeMs, | ||
| const bsl::shared_ptr<bmqio::Channel>& channel_sp) | ||
| { | ||
| // executed by an *AUTHENTICATION* thread | ||
|
|
||
| // PRECONDITION | ||
| BSLS_ASSERT_SAFE(scheduler_p); | ||
| BSLS_ASSERT_SAFE(channel_sp); | ||
|
|
||
| bslmt::LockGuard<bslmt::Mutex> guard(&d_mutex); // LOCKED | ||
|
|
@@ -175,14 +176,14 @@ int AuthenticationContext::setAuthenticatedAndScheduleReauthn( | |
|
|
||
| d_state = AuthenticationState::e_AUTHENTICATED; | ||
|
|
||
| scheduler_p->cancelEventAndWait(&d_timeoutHandle); | ||
| d_scheduler_p->cancelEventAndWait(&d_timeoutHandle); | ||
|
|
||
| if (!lifetimeMs.has_value()) { | ||
| return 0; | ||
| } | ||
| const bsls::Types::Uint64 lifetime = lifetimeMs.value(); | ||
|
|
||
| scheduler_p->scheduleEvent( | ||
| d_scheduler_p->scheduleEvent( | ||
| &d_timeoutHandle, | ||
| bsls::TimeInterval(bmqu::Time::nowMonotonicClock()) | ||
| .addMilliseconds(lifetime), | ||
|
|
@@ -250,21 +251,18 @@ void AuthenticationContext::onReauthenticationError( | |
| channel_sp->close(status); | ||
| } | ||
|
|
||
| void AuthenticationContext::onClose(bdlmt::EventScheduler* scheduler_p) | ||
| void AuthenticationContext::onClose() | ||
| { | ||
| // executed by *ANY* thread | ||
|
|
||
| // PRECONDITIONS | ||
| BSLS_ASSERT_SAFE(scheduler_p); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not null due to invariant check on construction |
||
|
|
||
| bslmt::LockGuard<bslmt::Mutex> guard(&d_mutex); // LOCKED | ||
|
|
||
| if (d_state == AuthenticationState::e_CLOSED) { | ||
| return; // idempotent | ||
| } | ||
| d_state = AuthenticationState::e_CLOSED; | ||
|
|
||
| scheduler_p->cancelEventAndWait(&d_timeoutHandle); | ||
| d_scheduler_p->cancelEventAndWait(&d_timeoutHandle); | ||
| } | ||
|
|
||
| bool AuthenticationContext::tryStartReauthentication() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -278,14 +278,14 @@ class InitialConnectionContext { | |
| bsl::shared_ptr<NegotiationUserData> d_userData_sp; | ||
|
|
||
| /// The channel to use for the initial connection. | ||
| bsl::shared_ptr<bmqio::Channel> d_channelSp; | ||
| bsl::shared_ptr<bmqio::Channel> d_channel_sp; | ||
|
|
||
| /// The AuthenticationContext updated upon receiving an | ||
| /// authentication message. | ||
| bsl::shared_ptr<AuthenticationContext> d_authenticationCtxSp; | ||
| bsl::shared_ptr<AuthenticationContext> d_authenticationCtx_sp; | ||
|
|
||
| /// The NegotiationContext updated upon receiving a negotiation message. | ||
| bsl::shared_ptr<NegotiationContext> d_negotiationCtxSp; | ||
| bsl::shared_ptr<NegotiationContext> d_negotiationCtx_sp; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BDE convention to have |
||
|
|
||
| /// The callback to invoke to notify of the status of the initial | ||
| /// connection. | ||
|
|
@@ -394,7 +394,7 @@ class InitialConnectionContext { | |
| void setAuthenticationContext( | ||
| const bsl::shared_ptr<AuthenticationContext>& value); | ||
|
|
||
| /// Called by the IO upon `onClose` signal | ||
| /// @brief Called by the IO upon `onClose` signal. | ||
| void onClose(); | ||
|
|
||
| /// Read callback invoked when data is available on the channel. | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cached single scheduler
d_scheduler_pso we have a guarantee that the same scheduler is used for both scheduling/cancelling events.Before, the API has weakness, allowing providing different schedulers