Changeset - 7e4b7b7026e6
[Not reviewed]
2 14 0
Christopher Esterhuyse - 5 years ago 2020-04-30 11:46:24
christopher.esterhuyse@gmail.com
simplified examples and added more user interaction
16 files changed with 142 insertions and 269 deletions:
0 comments (0 inline, 0 general)
examples/1_socketlike/amy.c
Show inline comments
 
@@ -2,47 +2,35 @@
 
#include <string.h>
 
#include "../../reowolf.h"
 
#include "../utility.c"
 

	
 
int main() {
 
	
 
	// amy hard-codes her protocol.
 
	// Protocol is hard-coded.
 
	char* pdl =
 
	"primitive forward(in i, out o) {"
 
	"	while(true) synchronous {"
 
	"		put(o, get(i));"
 
	"	}"
 
	"}"
 
	;
 
	
 
	// fill a buffer with the user's message to send.
 
	char msg_buf[128];
 
	memset(msg_buf, 0, 128);
 
	printf("input a message to send:");
 
	check("fgets", fgets(msg_buf, 128-1, stdin) == NULL);
 
	int msg_len = strlen(msg_buf);
 
	msg_buf[msg_len-1] = 0;
 
	printf("will send msg `%s`\n", msg_buf);
 
	"  while(true) synchronous {     "
 
	"    put(o, get(i));             "
 
	"  }                             "
 
	"}                               ";
 
	
 
	// create a connector with one outgoing network channel.
 
	Connector* c = connector_new();
 
	printf("configuring...\n");
 
	check("config ", connector_configure(c, pdl, "forward"));
 
	check("bind 0 ", connector_bind_native(c, 0));
 
	check("bind 1 ", connector_bind_passive(c, 1, "127.0.0.1:7000"));
 
	printf("connecting...\n");
 
	check("connect", connector_connect(c, 5000));
 
	
 
	// send the user-provided message three times
 
	// send "hello" message three times
 
	int i;
 
	for (i = 0; i < 3; i++) {
 
		check("put ", connector_put(c, 0, msg_buf, msg_len));
 
		check("put ", connector_put(c, 0, "hello", 5));
 
		check("sync", connector_sync(c, 1000));
 
		printf("Sent one message!\n");
 
	}
 
	
 
	// clean up
 
	printf("destroying...\n");
 
	printf("cleaning up\n");
 
	connector_destroy(c);
 
	printf("exiting...\n");
 
	return 0;
 
}
 
\ No newline at end of file
examples/1_socketlike/bob.c
Show inline comments
 
#include <stdio.h>
 
#include "../../reowolf.h"
 
#include "../utility.c"
 

	
 
int main() {
 

	
 
	// bob hard-codes his protocol.
 
	// Protocol is hard-coded.
 
	char* pdl =
 
	"primitive forward(in i, out o) {"
 
	"	while(true) synchronous {"
 
	"		put(o, get(i));"
 
	"	}"
 
	"}"
 
	;
 
	"  while(true) synchronous {     "
 
	"    put(o, get(i));             "
 
	"  }                             "
 
	"}                               ";
 
	
 
	// setup a connector with one incoming network channel.
 
	Connector* c = connector_new();
 
	printf("configuring...\n");
 
	check("config ", connector_configure(c, pdl, "forward"));
 
	check("bind 0 ", connector_bind_active(c, 0, "127.0.0.1:7000"));
 
	check("bind 1 ", connector_bind_native(c, 1));
 
	printf("connecting...\n");
 
	printf("connect err %d%n", connector_connect(c, 20000));
 
	printf("%s%n", connector_dump_log(c));
 
	check("config  ", connector_configure(c, pdl, "forward"));
 
	check("bind 0  ", connector_bind_active(c, 0, "127.0.0.1:7000"));
 
	check("bind 1  ", connector_bind_native(c, 1));
 
	check("connect ", connector_connect(c, 5000));
 
	
 
	// receive a message and print it to stdout three times
 
	int i;
 
	int i, msg_len;
 
	const unsigned char * msg;
 
	for (i = 0; i < 3; i++) {
 
		check("get ", connector_get(c, 0));
 
		check("sync", connector_sync(c, 1000));
 

	
 
		int msg_len;
 
		const unsigned char * msg;
 
		check("read", connector_gotten(c, 0, &msg, &msg_len));
 

	
 
		printf("Received one message `%s`!\n", msg);
 
		printf("Received one message `%.*s`!\n", msg_len, msg);
 
	}
 

	
 
	// cleanup
 
	printf("destroying...\n");
 
	
 
	printf("cleaning up\n");
 
	connector_destroy(c);
 
	printf("exiting...\n");
 
	return 0;
 
}
 
\ No newline at end of file
examples/2_dynamic_pdl/amy.c
Show inline comments
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <string.h>
 
#include "../../reowolf.h"
 
#include "../utility.c"
 

	
 
int main() {
 

	
 
	// amy's protocol is loaded at runtime from a file.
 
	char * pdl = buffer_pdl("eg_protocols.pdl");
 
	
 
	char msg_buf[128];
 
	memset(msg_buf, 0, 128);
 
	printf("input a message to send:");
 
	check("fgets", fgets(msg_buf, 128-1, stdin) == NULL);
 
	int msg_len = strlen(msg_buf);
 
	msg_buf[msg_len-1] = 0;
 
	printf("will send msg `%s`\n", msg_buf);
 
	// Protocol is loaded from file.
 
	char * pdl = buffer_pdl("eg_protocols.pdl");
 
	
 
	// create a connector with one outgoing network channel.
 
	Connector* c = connector_new();
 
	printf("configuring...\n");
 
	check("config ", connector_configure(c, pdl, "forward"));
 
	check("bind 0 ", connector_bind_native(c, 0));
 
	check("bind 1 ", connector_bind_passive(c, 1, "127.0.0.1:7000"));
 
	printf("connecting...\n");
 
	check("connect", connector_connect(c, 5000));
 
	
 
	// send "hello" message three times
 
	int i;
 
	for (i = 0; i < 3; i++) {
 
		check("put ", connector_put(c, 0, msg_buf, msg_len));
 
		check("put ", connector_put(c, 0, "hello", 5));
 
		check("sync", connector_sync(c, 1000));
 
		printf("Sent one message!\n");
 
	}
 
	
 
	printf("destroying...\n");
 
	printf("cleaning up\n");
 
	connector_destroy(c);
 
	printf("exiting...\n");
 
	free(pdl);
 
	return 0;
 
}
 
\ No newline at end of file
examples/2_dynamic_pdl/bob.c
Show inline comments
 
deleted file
examples/2_dynamic_pdl/make.sh
Show inline comments
 
#!/bin/sh
 

	
 
LIB_PATH="../../target/release"
 
gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH amy.c -o amy
 
gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH bob.c -o bob
 
gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH amy.c -o amy
 
\ No newline at end of file
examples/3_nondeterminism/amy.c
Show inline comments
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <string.h>
 
#include "../../reowolf.h"
 
#include "../utility.c"
 

	
 
// amy indefinitely offers 0/1 messages with contents: the number of total sent messages
 
int main() {
 
	char * pdl = buffer_pdl("eg_protocols.pdl");
 
	
 
	Connector* c = connector_new();
 
	printf("configuring...\n");
 
	check("config ", connector_configure(c, pdl, "sync"));
 
@@ -17,29 +18,31 @@ int main() {
 

	
 
	// amy offers a message to her peer.
 
	// the message is the number of messages the peer previously received.
 

	
 
	int send_next = 0;
 
	char msg_buf[32];
 
	int code;
 
	int i;
 
	int code, i;
 
	for (i = 0; 1; i++) {
 
		itoa(send_next, msg_buf, 10);
 
		printf("\nround %d. Will send msg `%s` next", i, msg_buf);
 
		printf("\nround %d. Will send msg `%s` next\n", i, msg_buf);
 
		
 
		// option (a): no messages sent
 
		check("next_batch ", connector_next_batch(c));
 
		
 
		// option (b): one message sent
 
		check("put ", connector_put(c, 0, msg_buf, strlen(msg_buf) + 1));
 
		
 
		code = connector_sync(c, 3000);
 
		check("sync ", code);
 
		
 
		// reflect on the outcome of the exchange
 
		if (code == 0) printf("Sent no message!");
 
		else if (code == 1) {
 
			printf("Sent message `%s`!", msg_buf);
 
		if (code == 0) {
 
			printf("Sent no message!\n");
 
		} else if (code == 1) {
 
			printf("Sent message `%s`!\n", msg_buf);
 
			send_next++;
 
		} else {
 
			printf(
 
				"Connector error! %d (%s)\nBreaking loop!\n",
 
				code, connector_error_peek()
 
			);
examples/3_nondeterminism/bob.c
Show inline comments
 
#include <stdio.h>
 
#include <time.h>
 
#include "../../reowolf.h"
 
#include "../utility.c"
 

	
 
// bob indefinitely chooses between receiving or not receiving a message (user inputs y/n)
 
int main() {
 
	char * pdl = buffer_pdl("eg_protocols.pdl");
 

	
 
	Connector* c = connector_new();
 
	printf("configuring...\n");
 
	check("config ", connector_configure(c, pdl, "sync"));
 
	char * pdl = buffer_pdl("eg_protocols.pdl");
 
	check("config ", connector_configure(c, pdl, "bob3"));
 
	check("bind 0 ", connector_bind_active(c, 0, "127.0.0.1:7000"));
 
	check("bind 1 ", connector_bind_native(c, 1));
 

	
 
	printf("connecting...\n");
 
	check("connect", connector_connect(c, 5000));
 

	
 
	int msg_len, i;
 
	const unsigned char * msg;
 
	srand(time(NULL));
 
	for (i = 0; i < 10; i++) {
 
	int i, code, msg_len;
 
	char yn;
 
	
 
	for (i = 0; true; i++) {
 
		printf("\nround %d...\n", i);
 
		int random = rand() % 2;
 
		if (random == 0) {
 
			printf("I don't want a message!\n");
 
			check("sync", connector_sync(c, 1000));
 
		printf("Should I receive a message? (y/n): ");
 
		scanf(" %c", &yn);
 
		if (yn == 'y') {
 
			printf("OK! Let's receive a message!\n");
 
			connector_get(c, 0);
 
		} else if (yn == 'n') {
 
			printf("OK! Let's NOT receive a message!\n");
 
		} else {
 
			printf("I want a message!\n");
 
			check("get ", connector_get(c, 0));
 
			check("sync", connector_sync(c, 1000));
 
			check("read msg", connector_gotten(c, 0, &msg, &msg_len));
 
			printf("Expected (y/n) input!");
 
			continue;
 
		}
 
		check("sync ", connector_sync(c, 1000));
 
		if (yn == 'y') {
 
			check("read ", connector_gotten(c, 0, &msg, &msg_len));
 
			printf("Got message: `%.*s`\n", msg_len, msg);
 
		}
 
	}
 
	
 
	printf("destroying...\n");
 

	
 
	printf("cleaning up\n");
 
	connector_destroy(c);
 
	printf("exiting...\n");
 
	free(pdl);
 
	return 0;
 
}
 
\ No newline at end of file
examples/4_atomicity/amy.c
Show inline comments
 
@@ -15,14 +15,13 @@ int main() { // AMY
 
	check("bind 1 ", connector_bind_native(c, 1));
 
	check("bind 2 ", connector_bind_passive(c, 2, "127.0.0.1:7000"));
 
	check("bind 3 ", connector_bind_passive(c, 3, "127.0.0.1:7001"));
 
	printf("connecting...\n");
 
	check("connect", connector_connect(c, 5000));
 

	
 
	int i;
 
	int code;
 
	int i, code;
 
	while (1) {
 
		printf("\nround %d\n", i);
 
		
 
		// batch 0: no messages sent
 
		check("next_batch ", connector_next_batch(c));
 
		
 
@@ -30,21 +29,21 @@ int main() { // AMY
 
		check("put ", connector_put(c, 0, "one", 3));
 
		check("put ", connector_put(c, 1, "two", 3));
 
		code = connector_sync(c, 3000);
 
		
 
		if (code == 0) printf("Sent neither message!");
 
		else if (code == 1) printf("Sent both messages!");
 
		else if (code == -1) printf("Sync failed!\n");
 
		else {
 
			printf(
 
				"Connector error! %d (%s)\nBreaking loop!\n",
 
				code, connector_error_peek()
 
			);
 
			break;
 
		}
 
	}
 
	
 
	printf("destroying...\n");
 
	printf("cleaning up...\n");
 
	connector_destroy(c);
 
	printf("exiting...\n");
 
	free(pdl);
 
	return 0;
 
}
 
\ No newline at end of file
examples/4_atomicity/bob.c
Show inline comments
 
#include <stdio.h>
 
#include "../../reowolf.h"
 
#include "../utility.c"
 

	
 
int main() { // BOB!
 
	char * pdl = buffer_pdl("eg_protocols.pdl");
 
	Connector* c = connector_new();
 
int main() {
 

	
 
	Connector* c = connector_new();
 
	printf("configuring...\n");
 
	char * pdl = buffer_pdl("eg_protocols.pdl");
 
	check("config ", connector_configure(c, pdl, "sync_two"));
 

	
 
	check("bind 0 ", connector_bind_active(c, 0, "127.0.0.1:7000"));
 
	check("bind 1 ", connector_bind_active(c, 1, "127.0.0.1:7001"));
 
	check("bind 2 ", connector_bind_native(c, 2));
 
	check("bind 3 ", connector_bind_native(c, 3));
 

	
 
	printf("connecting...\n");
 
	check("connect", connector_connect(c, 5000));
 

	
 
	int msg_len;
 
	const unsigned char * msg;
 

	
 
	int i;
 
	const char * nth[2] = {"first", "second"};
 
	int i, code, msg_len;
 
	char yn[2];
 
	
 
	// rounds 0..=2: get both messages
 
	for (i = 0; i <= 2; i++) {
 
		printf("\nround %d\n", i);
 
		
 
		check("get ", connector_get(c, 0));
 
		check("get ", connector_get(c, 1));
 
		check("sync", connector_sync(c, 1000));
 
		
 
		check("read one", connector_gotten(c, 0, &msg, &msg_len));
 
		printf("Got message one: `%.*s`\n", msg_len, msg);
 
		
 
		check("read two", connector_gotten(c, 1, &msg, &msg_len));
 
		printf("Got message two: `%.*s`\n", msg_len, msg);
 
	}
 
	// rounds 3..=5: get neither message
 
	for (i = 3; i <= 5; i++) {
 
		printf("\nround %d\n", i);
 
		
 
		//check("get ", connector_get(c, 0));
 
		//check("get ", connector_get(c, 1));
 
		check("sync", connector_sync(c, 3000));
 
		
 
		//check("read one", connector_gotten(c, 0, &msg, &msg_len));
 
		//printf("Got message one: `%.*s`\n", msg_len, msg);
 
		
 
		//check("read two", connector_gotten(c, 1, &msg, &msg_len));
 
		//printf("Got message two: `%.*s`\n", msg_len, msg);
 
	}
 
	// round 6: attempt to get just one message
 
	for (i = 6; i <= 6; i++) {
 
		printf("\nround %d\n", i);
 
		
 
		check("get ", connector_get(c, 0));
 
		//check("get ", connector_get(c, 1));
 
		check("sync", connector_sync(c, 3000));
 
		
 
		//check("read one", connector_gotten(c, 0, &msg, &msg_len));
 
		//printf("Got message one: `%.*s`\n", msg_len, msg);
 
		
 
		check("read two", connector_gotten(c, 1, &msg, &msg_len));
 
		printf("Got message two: `%.*s`\n", msg_len, msg);
 
	while(true) {
 
		printf("\nround %d...\n", i);
 
		printf("Which of the two messages should we receive? (y/n)(y/n) (eg: yy): ");
 
		scanf(" %c%c", &yn[0], &yn[1]);
 
		for (i = 0; i < 2; i++) {
 
			if (yn[i] != 'y' && yn[i] != 'n') {
 
				printf("Expected (y/n) input!");
 
				continue;
 
			}
 
		}
 
		printf("Receiving messages [%c, %c]\n", yn[0], yn[1]);
 
		if (yn[0] == 'y') check("get first  ", connector_get(c, 0));
 
		if (yn[1] == 'y') check("get second ", connector_get(c, 1));
 
		check("sync ", connector_sync(c, 3000));
 
		for (i = 0; i < 2; i++) {
 
			if (yn[i] == 'y') {
 
				check("read ", connector_gotten(c, i, &msg, &msg_len));
 
				printf("Got %s msg `%.*s`\n", nth[i], msg_len, msg);
 
			}
 
		}
 
	}
 
	
 
	printf("destroying...\n");
 

	
 
	printf("cleaning up\n");
 
	connector_destroy(c);
 
	printf("exiting...\n");
 
	free(pdl);
 
	return 0;
 
}
 
\ No newline at end of file
examples/5_recovery/amy.c
Show inline comments
 
deleted file
examples/5_recovery/bob.c
Show inline comments
 
#include <stdio.h>
 
#include "../../reowolf.h"
 
#include "../utility.c"
 

	
 
int main() { // BOB!
 
int main() {
 

	
 
	char * pdl = buffer_pdl("eg_protocols.pdl");
 
	Connector* c = connector_new();
 

	
 
	printf("configuring...\n");
 
	check("config ", connector_configure(c, pdl, "recovery_bob"));
 
	char * pdl = buffer_pdl("eg_protocols.pdl");
 
	check("config ", connector_configure(c, pdl, "sync_two"));
 
	check("bind 0 ", connector_bind_active(c, 0, "127.0.0.1:7000"));
 
	check("bind 1 ", connector_bind_native(c, 1));
 
	check("bind 1 ", connector_bind_active(c, 1, "127.0.0.1:7001"));
 
	check("bind 2 ", connector_bind_native(c, 2));
 
	check("bind 3 ", connector_bind_native(c, 3));
 

	
 
	printf("connecting...\n");
 
	check("connect", connector_connect(c, 5000));
 

	
 
	int msg_len;
 
	const unsigned char * msg;
 

	
 
	int i;
 
	char msg_buf[1];
 
	int code;
 
	char answer;
 
	const char * nth[2] = {"first", "second"};
 
	int i, code, msg_len;
 
	char yn[2];
 
	
 
	for (i = 0; true; i++) {
 
	while(true) {
 
		printf("\nround %d...\n", i);
 
		printf("Should I receive a message? (y/n): ");
 
		scanf(" %c", &answer);
 
		if (answer == 'y') {
 
			printf("OK! Let's receive a message!\n");
 
			connector_get(c, 0);
 
		} else if (answer == 'n') {
 
			printf("OK! Let's NOT receive a message!\n");
 
		} else {
 
			printf("Expected (y/n) input!");
 
		printf("Which of the two messages should we receive? (y/n)(y/n) (eg: yy): ");
 
		scanf(" %c%c", &yn[0], &yn[1]);
 
		for (i = 0; i < 2; i++) {
 
			if (yn[i] != 'y' && yn[i] != 'n') {
 
				printf("Expected (y/n) input!");
 
				continue;
 
			}
 
		}
 
		printf("Receiving messages [%c, %c]\n", yn[0], yn[1]);
 
		if (yn[0] == 'y') check("get first  ", connector_get(c, 0));
 
		if (yn[1] == 'y') check("get second ", connector_get(c, 1));
 
			
 
		code = connector_sync(c, 1000);
 
		if (code == 0) printf("sync succeeded!\n");
 
		else if (code == -1) {
 
			printf("sync failed; state recovered!\n");
 
			continue;
 
		} else {
 
			printf("Unrecoverable error! code %d\n", code);
 
			connector_dump_log(c);
 
		}
 
		
 
		code = connector_sync(c, 1000);
 
			
 
		// lets see how it went
 
		if (code == 0) {
 
			printf("Success!\n");
 
			if (answer == 'y') {
 
				check("read ", connector_gotten(c, 0, &msg, &msg_len));
 
				printf("Got message: `%.*s`\n", msg_len, msg);
 
		for (i = 0; i < 2; i++) {
 
			if (yn[i] == 'y') {
 
				check("read ", connector_gotten(c, i, &msg, &msg_len));
 
				printf("Got %s msg `%.*s`\n", nth[i], msg_len, msg);
 
			}
 
		} else if (code == -1) {
 
			printf("!!! UH OH! The round rolled back! Let's try again\n");
 
		} else {
 
			printf(
 
				"Something went wrong!\n",
 
				code, connector_error_peek()
 
			);
 
			break;
 
		}
 
	}
 
	
 
	printf("destroying...\n");
 

	
 
	printf("cleaning up\n");
 
	connector_destroy(c);
 
	printf("exiting...\n");
 
	free(pdl);
 
	return 0;
 
}
 
\ No newline at end of file
examples/5_recovery/make.sh
Show inline comments
 
#!/bin/sh
 

	
 
LIB_PATH="../"
 
gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH amy.c -o amy
 
gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH bob.c -o bob
examples/6_constraint_solve/main.c
Show inline comments
 
@@ -45,13 +45,13 @@ const char* addrs[] = {
 
	"127.0.0.1:7002",
 
	"127.0.0.1:7003",
 
	"127.0.0.1:7004",
 
	"127.0.0.1:7005",
 
};
 
int main(int arg_c, char * argv[]) {
 
	int my_id, peer_id, i;
 
	int my_id, peer_id, i, code;
 
	if (arg_c != 2) {
 
		printf("Expected one arg: which peer I am in 0..4");
 
		return 1;
 
	}
 
	my_id = atoi(argv[1]);
 
	assert(0 <= my_id && my_id < N);
 
@@ -90,16 +90,15 @@ int main(int arg_c, char * argv[]) {
 
		check("op ", pi->puts?
 
			connector_get(c, i):
 
			connector_put(c, i, NULL, 0));
 
	}
 
	// solve!
 
	printf("solving...\n");
 
	int batch_idx = connector_sync(c, 3000);
 
	if (batch_idx < 0) printf("Error code on sync! %d\n", batch_idx);
 
	else printf("{ me: %d, peer: %d }\n", my_id, peer_infos[batch_idx].id);
 
	code = connector_sync(c, 3000);
 
	if (code < 0) printf("Error code on sync! %d\n", code);
 
	else printf("{ my_id: %d, peer_id: %d }\n", my_id, peer_infos[code].id);
 
	
 
	printf("destroying...\n");
 
	printf("cleanup...\n");
 
	connector_destroy(c);
 
	printf("exiting...\n");
 
	free(pdl);
 
	return 0;
 
}
 
\ No newline at end of file
examples/eg_protocols.pdl
Show inline comments
 
@@ -17,13 +17,16 @@ primitive sync_two(in ia, in ib, out oa, out ob) {
 
			put(oa, get(ia));
 
			put(ob, get(ib));
 
		}
 
	}
 
}
 

	
 
composite recovery_bob(in i, out o) {
 
composite bob3(in i, out o) {
 
	new sync(i, o);
 
}
 
composite bob5(in i, out o) {
 
	new sync(i, o);
 
}
 

	
 
primitive xor_three(in ai, out ao, in bi, out bo, in ci, out co) {
 
	synchronous {
 
		if      (fires(ai)) put(ao, get(ai));
examples/utility.c
Show inline comments
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <errno.h>
 

	
 
void check(const char* phase, int err) {
 
	if (err) {
 
void check(const char* phase, int code) {
 
	if (code < 0) {
 
		printf("ERR %d in phase `%s`. Err was `%s`\nEXITING!\n",
 
			err, phase, connector_error_peek());
 
			code, phase, connector_error_peek());
 
		exit(1);
 
	}
 
}
 

	
 
// allocates a buffer!
 
char * buffer_pdl(char * filename) {
src/runtime/setup.rs
Show inline comments
 
@@ -241,15 +241,15 @@ impl Controller {
 
                        if Self::connection_testing_read(stream, &mut next_inbox).is_err() {
 
                            return Err(PassiveConnectFailed(*addr));
 
                        }
 
                        ms.poll.reregister(stream, token, ready_r, edge).expect("52");
 
                        let mut res = Ok(());
 
                        take_mut::take(entry, |e| {
 
                            let mut inbox = vec![];
 
                            std::mem::swap(&mut inbox, &mut next_inbox);
 
                            assert_let![PassiveConnecting { info, stream, .. } = e => {
 
                                let mut inbox = vec![];
 
                                std::mem::swap(&mut inbox, &mut next_inbox);
 
                                let mut endpoint = Endpoint::from_fresh_stream_and_inbox(stream, inbox);
 
                                let msg = Msg::SetupMsg(SetupMsg::ChannelSetup { info });
 
                                res = endpoint.send(msg);
 
                                Finished(EndpointExt { info, endpoint })
 
                            }]
 
                        });
 
@@ -262,15 +262,15 @@ impl Controller {
 
                        assert!(event.readiness().is_writable());
 
                        if Self::connection_testing_read(stream, &mut next_inbox).is_ok() {
 
                            // connect successful
 
                            log!(logger, "Connectivity test passed");
 
                            ms.poll.reregister(stream, token, ready_r, edge).expect("52");
 
                            take_mut::take(entry, |e| {
 
                                assert_let![ActiveConnecting { stream, polarity, addr } = e => {
 
                                let mut inbox = vec![];
 
                                std::mem::swap(&mut inbox, &mut next_inbox);
 
                                assert_let![ActiveConnecting { stream, polarity, addr } = e => {
 
                                    let endpoint = Endpoint::from_fresh_stream_and_inbox(stream, inbox);
 
                                    ActiveRecving { endpoint, polarity, addr }
 
                                }]
 
                            });
 
                        } else {
 
                            // connect failure. retry!
0 comments (0 inline, 0 general)