Skip to content

Commit c319206

Browse files
authored
tsan weak_from_this race (#248)
Signed-off-by: turuslan <[email protected]>
1 parent 4caaa47 commit c319206

4 files changed

Lines changed: 9 additions & 2 deletions

File tree

include/libp2p/protocol/kademlia/impl/content_routing_table.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ namespace libp2p::protocol::kademlia {
2828
struct ContentRoutingTable {
2929
virtual ~ContentRoutingTable() = default;
3030

31+
virtual void start() = 0;
32+
3133
virtual void addProvider(const ContentId &key,
3234
const peer::PeerId &peer) = 0;
3335

include/libp2p/protocol/kademlia/impl/content_routing_table_impl.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ namespace libp2p::protocol::kademlia {
5757

5858
~ContentRoutingTableImpl() override;
5959

60+
void start() override;
61+
6062
std::vector<PeerId> getProvidersFor(const ContentId &key,
6163
size_t limit = 0) const override;
6264

src/protocol/kademlia/impl/content_routing_table_impl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ namespace libp2p::protocol::kademlia {
1919
: config_(config), scheduler_(scheduler), bus_(std::move(bus)) {
2020
BOOST_ASSERT(bus_ != nullptr);
2121
table_ = std::make_unique<Table>();
22+
}
2223

23-
cleanup_timer_ =
24-
scheduler_.scheduleWithHandle([this] { setTimerCleanup(); });
24+
void ContentRoutingTableImpl::start() {
25+
setTimerCleanup();
2526
}
2627

2728
ContentRoutingTableImpl::~ContentRoutingTableImpl() = default;

src/protocol/kademlia/impl/kademlia_impl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ namespace libp2p::protocol::kademlia {
6464
}
6565
started_ = true;
6666

67+
content_routing_table_->start();
68+
6769
// save himself into peer repo
6870
addPeer(host_->getPeerInfo(), true);
6971

0 commit comments

Comments
 (0)