From ecc163f98e434b557768560d00ee2f9755d6d950 Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 14 Nov 2018 22:18:59 -0500 Subject: major bug fix --- test/test_network.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'test/test_network.cpp') diff --git a/test/test_network.cpp b/test/test_network.cpp index d93d0ff..d52b6c2 100644 --- a/test/test_network.cpp +++ b/test/test_network.cpp @@ -132,7 +132,14 @@ salticidae::EventContext ec; NetAddr alice_addr("127.0.0.1:12345"); NetAddr bob_addr("127.0.0.1:12346"); +void signal_handler(int) { + throw salticidae::SalticidaeError("got termination signal"); +} + int main() { + signal(SIGTERM, signal_handler); + signal(SIGINT, signal_handler); + /* test two nodes */ MyNet alice(ec, "Alice", bob_addr); MyNet bob(ec, "Bob", alice_addr); @@ -141,16 +148,18 @@ int main() { alice.reg_handler(on_receive_ack); bob.reg_handler(on_receive_ack); - alice.start(); - bob.start(); + try { + alice.start(); + bob.start(); - alice.listen(alice_addr); - bob.listen(bob_addr); + alice.listen(alice_addr); + bob.listen(bob_addr); - /* first attempt */ - alice.connect(bob_addr); - bob.connect(alice_addr); + /* first attempt */ + alice.connect(bob_addr); + bob.connect(alice_addr); - ec.dispatch(); + ec.dispatch(); + } catch (salticidae::SalticidaeError &e) {} return 0; } -- cgit v1.2.3