aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2018-11-12 15:52:38 -0500
committerDeterminant <[email protected]>2018-11-12 15:52:38 -0500
commit7387f7f6b615717dd863bcb62ee7f65ace29879b (patch)
tree19dfd53b8da5a01858e14fd43184683270deec15 /test
parentdd09443b0b3c0b5d1a8c034644d1065dd25bf5a9 (diff)
update PeerNetwork to work with multiloops
Diffstat (limited to 'test')
-rw-r--r--test/bench_network.cpp9
-rw-r--r--test/test_network.cpp4
2 files changed, 8 insertions, 5 deletions
diff --git a/test/bench_network.cpp b/test/bench_network.cpp
index b1f1a0f..8ff9ab2 100644
--- a/test/bench_network.cpp
+++ b/test/bench_network.cpp
@@ -148,6 +148,10 @@ void signal_handler(int) {
}
int main() {
+ struct sigaction sa;
+ sa.sa_handler = signal_handler;
+ sigaction(SIGTERM, &sa, NULL);
+ sigaction(SIGINT, &sa, NULL);
/* test two nodes */
MyNet alice(ec, "Alice", bob_addr, 10);
alice.listen(alice_addr);
@@ -158,13 +162,12 @@ int main() {
try {
ec.dispatch();
} catch (std::exception &) {}
+ SALTICIDAE_LOG_INFO("exiting");
});
- signal(SIGTERM, signal_handler);
- signal(SIGINT, signal_handler);
try {
ec.dispatch();
} catch (std::exception &e) {
- pthread_kill(bob_thread.native_handle(), SIGINT);
+ pthread_kill(bob_thread.native_handle(), SIGTERM);
bob_thread.join();
SALTICIDAE_LOG_INFO("exception: %s", e.what());
}
diff --git a/test/test_network.cpp b/test/test_network.cpp
index c4fe2e2..1821ada 100644
--- a/test/test_network.cpp
+++ b/test/test_network.cpp
@@ -89,8 +89,8 @@ struct MyNet: public MsgNetworkByteOp {
reg_handler(salticidae::generic_bind(
&MyNet::on_receive_hello, this, _1, _2));
- reg_conn_handler([this](ConnPool::Conn &conn) {
- if (conn.get_fd() != -1)
+ reg_conn_handler([this](ConnPool::Conn &conn, bool connected) {
+ if (connected)
{
if (conn.get_mode() == ConnPool::Conn::ACTIVE)
{