From: Guus Sliepen Date: Sun, 13 Aug 2017 12:57:29 +0000 (+0200) Subject: Remove hack to wait for a valid key. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=3c56342ef05b0f81bcd9feba5d86e2bff8a0cb94;p=meshlink Remove hack to wait for a valid key. This was obviously only necessary because the missing retransmits of SYN packets. Now, if a channel is opened before we have finished the key exchange with the peer, UTCP will retry after a second. --- diff --git a/src/utcp b/src/utcp index d3b3b958..b2e5de6b 160000 --- a/src/utcp +++ b/src/utcp @@ -1 +1 @@ -Subproject commit d3b3b958b5555dfe0e20844135bff1d8b838f1dc +Subproject commit b2e5de6b537188f77e1889853f6ba919bf35c77c diff --git a/test/channels.c b/test/channels.c index 99a97a33..10369ca6 100644 --- a/test/channels.c +++ b/test/channels.c @@ -41,6 +41,7 @@ void foo_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void bar_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *data, size_t len) { printf("bar_receive_cb %zu: ", len); fwrite(data, 1, len, stdout); + printf("\n"); // Echo the data back. meshlink_channel_send(mesh, channel, data, len); } @@ -53,8 +54,8 @@ bool accept_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t po printf("accept_cb: (from %s on port %u) ", channel->node->name, (unsigned int)port); if(data) { fwrite(data, 1, len, stdout); - printf("\n"); } + printf("\n"); if(port != 7) return false; @@ -162,21 +163,10 @@ 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); - for(int i = 0; i < 5; i++) { + for(int i = 0; i < 20; i++) { sleep(1); if(bar_responded) break;