File tree Expand file tree Collapse file tree 5 files changed +59
-1
lines changed Expand file tree Collapse file tree 5 files changed +59
-1
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,10 @@ namespace libp2p::protocol {
15
15
interval_ (config.period_msec),
16
16
timer_(io, boost::posix_time::milliseconds(interval_)),
17
17
started_(boost::posix_time::microsec_clock::local_time()),
18
- timer_cb_([this ](const boost::system::error_code &) { onTimer (); }),
18
+ timer_cb_([this ](const boost::system::error_code &error) {
19
+ if (!error)
20
+ onTimer ();
21
+ }),
19
22
immediate_cb_ ([this ] { onImmediate (); }) {
20
23
assert (interval_ > 0 && interval_ <= 1000 );
21
24
timer_.async_wait (timer_cb_);
Original file line number Diff line number Diff line change 3
3
# SPDX-License-Identifier: Apache-2.0
4
4
#
5
5
6
+ add_subdirectory (common )
6
7
add_subdirectory (kademlia )
7
8
add_subdirectory (gossip )
8
9
Original file line number Diff line number Diff line change
1
+ #
2
+ # Copyright Soramitsu Co., Ltd. All Rights Reserved.
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ #
5
+
6
+ add_subdirectory (asio )
Original file line number Diff line number Diff line change
1
+ #
2
+ # Copyright Soramitsu Co., Ltd. All Rights Reserved.
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ #
5
+
6
+ addtest (asio_scheduler_test
7
+ asio_scheduler_test.cpp
8
+ )
9
+ target_link_libraries (asio_scheduler_test
10
+ asio_scheduler
11
+
12
+ p2p_basic_host
13
+ p2p_default_network
14
+ p2p_peer_repository
15
+ p2p_inmem_address_repository
16
+ p2p_inmem_key_repository
17
+ p2p_inmem_protocol_repository
18
+ p2p_literals
19
+ p2p_kad
20
+ asio_scheduler
21
+ )
Original file line number Diff line number Diff line change
1
+ /* *
2
+ * Copyright Soramitsu Co., Ltd. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ #include " libp2p/protocol/common/asio/asio_scheduler.hpp"
7
+
8
+ #include < gtest/gtest.h>
9
+ #include < libp2p/injector/host_injector.hpp>
10
+
11
+ using libp2p::protocol::Scheduler;
12
+
13
+ /* *
14
+ * @given Constructs AsioScheduler and schedules on io context and then deletes
15
+ * AsioScheduler
16
+ * @when context is run
17
+ * @then scheduler called and can handle cancellation timer without segfault
18
+ */
19
+ TEST (AsioScheduler, Construct) {
20
+ auto injector = libp2p::injector::makeHostInjector ();
21
+ auto context = injector.create <std::shared_ptr<boost::asio::io_context>>();
22
+ std::shared_ptr<Scheduler> scheduler =
23
+ std::make_shared<libp2p::protocol::AsioScheduler>(
24
+ *context, libp2p::protocol::SchedulerConfig{});
25
+ scheduler.reset ();
26
+ context->run ();
27
+ }
You can’t perform that action at this time.
0 commit comments