The channel test fails to work reliably when the two threads are started
exactly simultaneously and both sides try to connect to each other. Both
sides simultaneously initiate a end-to-end SPTPS connection by sending
the appropriate req_key request, but upon reception of each others
request they reset their own state, causing SPTPS packets from the old
and the new state to cross each other. A timeout will occur eventually,
causing one side to try to restart the SPTPS connection. Since the
timeouts are slightly randomized, this sometimes causes the channel test
to work, sometimes not.
// Import and export both side's data
meshlink_add_address(mesh1, "localhost");
- meshlink_add_address(mesh2, "localhost");
char *data = meshlink_export(mesh1);
if(!data) {
return 1;
}
- usleep(123456);
-
if(!meshlink_start(mesh2)) {
fprintf(stderr, "Bar could not start\n");
return 1;
return 1;
}
- sleep(1);
-
// Open a channel from foo to bar.
meshlink_node_t *bar = meshlink_get_node(mesh1, "bar");