mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Merge pull request #65051 from ClickHouse/fix_capture_this_in_context_access
Capture weak_ptr of ContextAccess for safety
This commit is contained in:
commit
cb84733143
@ -360,10 +360,13 @@ void ContextAccess::setUser(const UserPtr & user_) const
|
|||||||
|
|
||||||
subscription_for_roles_changes.reset();
|
subscription_for_roles_changes.reset();
|
||||||
enabled_roles = access_control->getEnabledRoles(current_roles, current_roles_with_admin_option);
|
enabled_roles = access_control->getEnabledRoles(current_roles, current_roles_with_admin_option);
|
||||||
subscription_for_roles_changes = enabled_roles->subscribeForChanges([this](const std::shared_ptr<const EnabledRolesInfo> & roles_info_)
|
subscription_for_roles_changes = enabled_roles->subscribeForChanges([weak_ptr = weak_from_this()](const std::shared_ptr<const EnabledRolesInfo> & roles_info_)
|
||||||
{
|
{
|
||||||
std::lock_guard lock{mutex};
|
auto ptr = weak_ptr.lock();
|
||||||
setRolesInfo(roles_info_);
|
if (!ptr)
|
||||||
|
return;
|
||||||
|
std::lock_guard lock{ptr->mutex};
|
||||||
|
ptr->setRolesInfo(roles_info_);
|
||||||
});
|
});
|
||||||
|
|
||||||
setRolesInfo(enabled_roles->getRolesInfo());
|
setRolesInfo(enabled_roles->getRolesInfo());
|
||||||
|
Loading…
Reference in New Issue
Block a user