Browse Source
PeerContext is used after being deleted, keep shared pointer to it. (#161)
Signed-off-by: Alexey-N-Chernyshov <alexey.n.chernyshov@gmail.com>
pull/163/head
Alexey
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
3 additions and
3 deletions
-
src/protocol/gossip/impl/connectivity.cpp
-
src/protocol/gossip/impl/stream.hpp
|
|
@ -50,9 +50,9 @@ namespace libp2p::protocol::gossip { |
|
|
|
// clang-format off
|
|
|
|
on_stream_event_ = |
|
|
|
[this, self_wptr=weak_from_this()] |
|
|
|
(const PeerContextPtr &from, outcome::result<Success> event) { |
|
|
|
(PeerContextPtr from, outcome::result<Success> event) { |
|
|
|
if (self_wptr.expired()) return; |
|
|
|
onStreamEvent(from, event); |
|
|
|
onStreamEvent(std::move(from), event); |
|
|
|
}; |
|
|
|
|
|
|
|
host_->setProtocolHandler( |
|
|
|
|
|
@ -23,7 +23,7 @@ namespace libp2p::protocol::gossip { |
|
|
|
class Stream : public std::enable_shared_from_this<Stream> { |
|
|
|
public: |
|
|
|
/// Feedback interface to its owning object (i.e. pub-sub instance)
|
|
|
|
using Feedback = std::function<void(const PeerContextPtr &from, |
|
|
|
using Feedback = std::function<void(PeerContextPtr from, |
|
|
|
outcome::result<Success> event)>; |
|
|
|
|
|
|
|
/// Ctor. N.B. Stream instance cannot live longer than its creators
|
|
|
|