Skip to content

Commit 522f9cb

Browse files
committed
Use weak_from_this
1 parent 2bea6b2 commit 522f9cb

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

include/simple_http.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ class Http2Parse final : public std::enable_shared_from_this<Http2Parse> {
940940
if (!sp) {
941941
return false;
942942
}
943-
std::weak_ptr<Http2Parse> self = shared_from_this();
943+
std::weak_ptr<Http2Parse> self = weak_from_this();
944944
asio::post(sp->get_executor(),
945945
[this,
946946
self = std::move(self),
@@ -979,7 +979,7 @@ class Http2Parse final : public std::enable_shared_from_this<Http2Parse> {
979979
if (!sp) {
980980
return false;
981981
}
982-
std::weak_ptr<Http2Parse> self = shared_from_this();
982+
std::weak_ptr<Http2Parse> self = weak_from_this();
983983
asio::post(sp->get_executor(),
984984
[this, self = std::move(self), data = std::move(data), write_mode, stream_id]() mutable {
985985
auto sp = self.lock();
@@ -2555,7 +2555,7 @@ class Http2Client final : public std::enable_shared_from_this<Http2Client> {
25552555
void(std::optional<std::tuple<std::shared_ptr<HttpRequestWriter>, std::shared_ptr<HttpResponseReader>>>)>
25562556
CompletionToken>
25572557
auto openStream(const std::shared_ptr<StreamSpec>& stream_spec, CompletionToken&& token) {
2558-
std::weak_ptr<Http2Client> self_ptr = shared_from_this();
2558+
std::weak_ptr<Http2Client> self_ptr = weak_from_this();
25592559
return asio::async_initiate<
25602560
CompletionToken,
25612561
void(std::optional<std::tuple<std::shared_ptr<HttpRequestWriter>, std::shared_ptr<HttpResponseReader>>>)>(
@@ -2820,7 +2820,7 @@ class Http2Client final : public std::enable_shared_from_this<Http2Client> {
28202820
sp->m_streams.clear();
28212821
co_return;
28222822
};
2823-
asio::co_spawn(*m_io_context, start_forward(socket_ptr, shared_from_this()), asio::detached);
2823+
asio::co_spawn(*m_io_context, start_forward(socket_ptr, weak_from_this()), asio::detached);
28242824

28252825
nghttp2_session_send(m_session);
28262826
}

0 commit comments

Comments
 (0)