From 86f3ebbac7f61dc44ca48dc67ba24bdb41e7cf4a Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" Date: Thu, 6 Nov 2014 18:39:33 +0100 Subject: [PATCH] hack to wait for SPTPS to complete before opening a channel --- test/channels.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/channels.c b/test/channels.c index 284a13b7..1958ad76 100644 --- a/test/channels.c +++ b/test/channels.c @@ -5,6 +5,7 @@ #include #include "../src/meshlink.h" +#include "../src/node.h" volatile bool bar_reachable = false; volatile bool bar_responded = false; @@ -153,6 +154,17 @@ int main(int argc, char *argv[]) { return 1; } + // XXX not enough to wait for reachable, must wait for SPTPS to complete + for(int i=0; i < 20; i++) { + sleep(1); + if(((node_t *)bar)->status.validkey) + break; + } + if(!((node_t *)bar)->status.validkey) { + fprintf(stderr, "No key exchange after 20 seconds\n"); + return 1; + } + meshlink_channel_t *channel = meshlink_channel_open(mesh1, bar, 7, foo_receive_cb, NULL, 0); meshlink_set_channel_poll_cb(mesh1, channel, poll_cb); -- 2.39.5