From: Matt Corallo Date: Sat, 25 Sep 2021 21:43:38 +0000 (+0000) Subject: Fix races in demo C++ bindings that can hang valgrind in CI X-Git-Tag: v0.0.101.2^2~1 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=aa7eb7c09b3d01dc125f42efed8d730c2062e4c4;p=ldk-c-bindings Fix races in demo C++ bindings that can hang valgrind in CI --- diff --git a/lightning-c-bindings/demo.cpp b/lightning-c-bindings/demo.cpp index e7b596b..a11c4bf 100644 --- a/lightning-c-bindings/demo.cpp +++ b/lightning-c-bindings/demo.cpp @@ -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)));