Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/groups/mqb/mqbnet/mqbnet_authenticationcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,22 @@ int AuthenticationContext::setAuthenticatedAndScheduleReauthn(
bmqu::WeakMemFnUtil::weakMemFn(
&AuthenticationContext::onReauthenticationTimeout,
d_self.acquireWeak()),
channel_sp, // channel_sp
lifetime // timeoutMs
bsl::weak_ptr<bmqio::Channel>(channel_sp), // channel_wp
lifetime // timeoutMs
));

return 0;
}

void AuthenticationContext::onReauthenticationTimeout(
const bsl::shared_ptr<bmqio::Channel>& channel_sp,
bsls::Types::Uint64 timeoutMs)
const bsl::weak_ptr<bmqio::Channel>& channel_wp,
bsls::Types::Uint64 timeoutMs)
{
// PRECONDITIONS
BSLS_ASSERT_SAFE(channel_sp);
bsl::shared_ptr<bmqio::Channel> channel_sp = channel_wp.lock();
if (!channel_sp) {
// The channel has already been destroyed; nothing to close.
return;
}

{
bslmt::LockGuard<bslmt::Mutex> guard(&d_mutex); // LOCKED
Expand Down
18 changes: 13 additions & 5 deletions src/groups/mqb/mqbnet/mqbnet_authenticationcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,19 @@ class AuthenticationContext {
const bsl::optional<bsls::Types::Uint64>& lifetimeMs,
const bsl::shared_ptr<bmqio::Channel>& channel_sp);

/// Close the specified `channel_sp` indicating that reauthentication was
/// not received within the specified `timeoutMs` (in milliseconds).
void onReauthenticationTimeout(
const bsl::shared_ptr<bmqio::Channel>& channel_sp,
bsls::Types::Uint64 timeoutMs);
/// @brief Close the channel on reauthentication timeout.
///
/// Close the channel referenced by `channel_wp`, indicating that
/// reauthentication was not received in time. A weak reference is held so
/// the pending timer does not extend the channel's lifetime; do nothing if
/// the channel has already been destroyed.
///
/// @param channel_wp Weak reference to the channel to close.
/// @param timeoutMs The reauthentication window, in milliseconds, that
/// elapsed without a reauthentication request.
void
onReauthenticationTimeout(const bsl::weak_ptr<bmqio::Channel>& channel_wp,
bsls::Types::Uint64 timeoutMs);

/// Close the specified `channel_sp` with the specified `errorCode` and
/// `errorDescription`, indicating a reauthentication error for the
Expand Down
Loading