Skip to content
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

Core: Only continue asio sessions inside lambda capture #6458

Merged
merged 1 commit into from
Nov 25, 2024
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
9 changes: 3 additions & 6 deletions src/login/auth_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ namespace

void auth_session::start()
{
auto self(shared_from_this());
if (socket_.lowest_layer().is_open())
{
// clang-format off
socket_.async_handshake(asio::ssl::stream_base::server,
[this, self](std::error_code ec)
[this, self = shared_from_this()](std::error_code ec)
{
if (!ec)
{
Expand All @@ -91,10 +90,9 @@ void auth_session::start()

void auth_session::do_read()
{
auto self(shared_from_this());
// clang-format off
socket_.async_read_some(asio::buffer(data_, max_length),
[this, self](std::error_code ec, std::size_t length)
[this, self = shared_from_this()](std::error_code ec, std::size_t length)
{
if (!ec)
{
Expand Down Expand Up @@ -530,10 +528,9 @@ void auth_session::read_func()

void auth_session::do_write(std::size_t length)
{
auto self(shared_from_this());
// clang-format off
asio::async_write(socket_, asio::buffer(data_, length),
[this, self](std::error_code ec, std::size_t /*length*/)
[this, self = shared_from_this()](std::error_code ec, std::size_t /*length*/)
{
if (!ec)
{
Expand Down
7 changes: 2 additions & 5 deletions src/login/handler_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ void handler_session::start()

void handler_session::do_read()
{
auto self(shared_from_this());

// clang-format off
socket_.next_layer().async_read_some(asio::buffer(data_, max_length),
[this, self](std::error_code ec, std::size_t length)
[this, self = shared_from_this()](std::error_code ec, std::size_t length)
{
if (!ec)
{
Expand All @@ -78,10 +76,9 @@ void handler_session::do_read()

void handler_session::do_write(std::size_t length)
{
auto self(shared_from_this());
// clang-format off
asio::async_write(socket_.next_layer(), asio::buffer(data_, length),
[this, self](std::error_code ec, std::size_t /*length*/)
[this, self = shared_from_this()](std::error_code ec, std::size_t /*length*/)
{
if (!ec)
{
Expand Down
Loading