]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Fix races in demo C++ bindings that can hang valgrind in CI
authorMatt Corallo <git@bluematt.me>
Sat, 25 Sep 2021 21:43:38 +0000 (21:43 +0000)
committerMatt Corallo <git@bluematt.me>
Sat, 25 Sep 2021 21:43:38 +0000 (21:43 +0000)
lightning-c-bindings/demo.cpp

index e7b596b0199a6e72a36f50c37ddcf9b45192c25d..a11c4bf9ccd6439e336fceb41543be23ba7a5351 100644 (file)
@@ -242,6 +242,9 @@ public:
                        if (peers_1->datalen == 0 && peers_2->datalen == 0) { break; }
                        std::this_thread::yield();
                }
+               // Note that the above is somewhat race-y, as node 2 may still think its connected.
+               // Thus, make sure any connections are disconnected on its end as well.
+               PeerManager_disconnect_by_node_id(&net2, ChannelManager_get_our_node_id(&cm1), false);
 
                // Finally make an actual connection and keep it this time
                assert(!socket_connect(node1_handler, ChannelManager_get_our_node_id(&cm2), (sockaddr*)&listen_addr, sizeof(listen_addr)));