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
parent
commit
6ee8c98862
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/protocol/gossip/impl/connectivity.cpp
  2. 2
      src/protocol/gossip/impl/stream.hpp

4
src/protocol/gossip/impl/connectivity.cpp

@ -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(

2
src/protocol/gossip/impl/stream.hpp

@ -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

Loading…
Cancel
Save