From 7e4b7b7026e683e9bf6440b00621518e78d0964d 2020-04-30 11:46:24 From: Christopher Esterhuyse Date: 2020-04-30 11:46:24 Subject: [PATCH] simplified examples and added more user interaction --- diff --git a/examples/1_socketlike/amy.c b/examples/1_socketlike/amy.c index 415c02f8fb45d06e44bbf95bc18cf4bb1f00729c..c03703226d87c2e461e965a0670c2dede7bed552 100644 --- a/examples/1_socketlike/amy.c +++ b/examples/1_socketlike/amy.c @@ -5,23 +5,13 @@ 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(); @@ -32,17 +22,15 @@ int main() { 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 diff --git a/examples/1_socketlike/bob.c b/examples/1_socketlike/bob.c index 2577e85a689bd56d9dac01840795c998e1c369aa..5457309363001adbd3038b6ec3c720b27958e6dc 100644 --- a/examples/1_socketlike/bob.c +++ b/examples/1_socketlike/bob.c @@ -4,41 +4,33 @@ 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 diff --git a/examples/2_dynamic_pdl/amy.c b/examples/2_dynamic_pdl/amy.c index 5a853ef2b5ed1f10c08331411edbddeb1b5d8654..f965c107d42368117f2b5f4ca7d39533142ed640 100644 --- a/examples/2_dynamic_pdl/amy.c +++ b/examples/2_dynamic_pdl/amy.c @@ -1,22 +1,14 @@ #include -#include #include #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")); @@ -25,16 +17,16 @@ int main() { 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 diff --git a/examples/2_dynamic_pdl/bob.c b/examples/2_dynamic_pdl/bob.c deleted file mode 100644 index e8db48ba8a58f62c37c1f479d9a41c504a916583..0000000000000000000000000000000000000000 --- a/examples/2_dynamic_pdl/bob.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include "../../reowolf.h" -#include "../utility.c" - -int main() { - - // bob's behavior is loaded from a file at runtime - char * pdl = buffer_pdl("eg_protocols.pdl"); - - 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"); - check("connect", connector_connect(c, 5000)); - - int i; - 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("destroying...\n"); - connector_destroy(c); - printf("exiting...\n"); - free(pdl); - return 0; -} \ No newline at end of file diff --git a/examples/2_dynamic_pdl/make.sh b/examples/2_dynamic_pdl/make.sh index 19ef6e33f1da63743e11033e0b06fecfa383072d..090a17a3ea6d33867de7e7ec53414c23789ffaa0 100644 --- a/examples/2_dynamic_pdl/make.sh +++ b/examples/2_dynamic_pdl/make.sh @@ -1,5 +1,4 @@ #!/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 diff --git a/examples/3_nondeterminism/amy.c b/examples/3_nondeterminism/amy.c index 7567b504528be3da36f135ba473ca3d84a27c3a7..a1db378c504569e946011b32ac1ba0a77f7f315d 100644 --- a/examples/3_nondeterminism/amy.c +++ b/examples/3_nondeterminism/amy.c @@ -4,6 +4,7 @@ #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"); @@ -20,23 +21,25 @@ int main() { 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( diff --git a/examples/3_nondeterminism/bob.c b/examples/3_nondeterminism/bob.c index 60981663b22bc66ea5cee6806e55ec2d5bed4d5a..5ece1f5b47085cbb8ab3d97ac1a107387f629398 100644 --- a/examples/3_nondeterminism/bob.c +++ b/examples/3_nondeterminism/bob.c @@ -1,40 +1,46 @@ #include -#include #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 diff --git a/examples/4_atomicity/amy.c b/examples/4_atomicity/amy.c index 82070a549a00f05f95f7aa77fbbfc07dfe4d482c..e7406dc01e23ff64daf9ce0e142414acdd0aefcf 100644 --- a/examples/4_atomicity/amy.c +++ b/examples/4_atomicity/amy.c @@ -18,8 +18,7 @@ int main() { // AMY printf("connecting...\n"); check("connect", connector_connect(c, 5000)); - int i; - int code; + int i, code; while (1) { printf("\nround %d\n", i); @@ -33,6 +32,7 @@ int main() { // AMY 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", @@ -42,9 +42,8 @@ int main() { // AMY } } - printf("destroying...\n"); + printf("cleaning up...\n"); connector_destroy(c); - printf("exiting...\n"); free(pdl); return 0; } \ No newline at end of file diff --git a/examples/4_atomicity/bob.c b/examples/4_atomicity/bob.c index 70689d964ffc3e2340b3dc37371049608dc18840..12dbd9cbbf8d96ed3afd749f462fe90dbb6e47b7 100644 --- a/examples/4_atomicity/bob.c +++ b/examples/4_atomicity/bob.c @@ -2,13 +2,12 @@ #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)); @@ -17,57 +16,35 @@ int main() { // BOB! 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 diff --git a/examples/5_recovery/amy.c b/examples/5_recovery/amy.c deleted file mode 100644 index 2d045ff9759041aab5e4c479e786336f8379436f..0000000000000000000000000000000000000000 --- a/examples/5_recovery/amy.c +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include -#include "../../reowolf.h" -#include "../utility.c" - -int main() { // AMY - char * pdl = buffer_pdl("eg_protocols.pdl"); - - Connector* c = connector_new(); - printf("configuring...\n"); - - check("config ", connector_configure(c, pdl, "sync")); - 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)); - - int i; - int code; - while (1) { - printf("\nround %d. I will offer the message \"hello\".\n", i); - connector_next_batch(c); - check("put ", connector_put(c, 0, "hello", 5)); - code = connector_sync(c, 3000); - - if (code == 0) printf("OK! No message was sent!"); - else if (code == 1) printf("OK! My message was received!"); - else if (code == -1) printf("!!! UH OH! The round rolled back! Let's try again"); - else { - printf( - "Something went wrong!\n", - code, connector_error_peek() - ); - break; - } - } - - printf("destroying...\n"); - connector_destroy(c); - printf("exiting...\n"); - free(pdl); - return 0; -} \ No newline at end of file diff --git a/examples/5_recovery/bob.c b/examples/5_recovery/bob.c index 91371cff82113e6c58d3dd225be6ae6960ca768c..0de10465504bc3fc136cb1ee3411d508a2b4df8d 100644 --- a/examples/5_recovery/bob.c +++ b/examples/5_recovery/bob.c @@ -2,64 +2,59 @@ #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 diff --git a/examples/5_recovery/make.sh b/examples/5_recovery/make.sh index 29265a080aec2c404da4a511f2c78a513596c536..76e7564aa5e4e27d9f1de8f7f7adc865f73ac9fe 100644 --- a/examples/5_recovery/make.sh +++ b/examples/5_recovery/make.sh @@ -1,5 +1,4 @@ #!/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 diff --git a/examples/6_constraint_solve/main.c b/examples/6_constraint_solve/main.c index e02af43d5cba36caa326432f120ec739b16ac169..76e87d4f8b18648ed70f9a9884b8b6038a226e9b 100644 --- a/examples/6_constraint_solve/main.c +++ b/examples/6_constraint_solve/main.c @@ -48,7 +48,7 @@ const char* addrs[] = { "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; @@ -93,13 +93,12 @@ int main(int arg_c, char * argv[]) { } // 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 diff --git a/examples/eg_protocols.pdl b/examples/eg_protocols.pdl index 0cf53722a500a19b91dff11ac48aba855c664578..27237f06cac58e23f76dcd03b8a42a327aecf811 100644 --- a/examples/eg_protocols.pdl +++ b/examples/eg_protocols.pdl @@ -20,7 +20,10 @@ primitive sync_two(in ia, in ib, out oa, out ob) { } } -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); } diff --git a/examples/utility.c b/examples/utility.c index fecf464f64ae5742fa6a24cd0086f8e7dc07fb8b..321a3ab691a09ad6adca26d3ea50a873ebd26208 100644 --- a/examples/utility.c +++ b/examples/utility.c @@ -2,10 +2,10 @@ #include #include -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); } } diff --git a/src/runtime/setup.rs b/src/runtime/setup.rs index 6bf4dc3ca693e7b4a5fb5fb430dd4fc63776f13d..6296c5feb66807ea14d489d7686bdbe5bbc30c3d 100644 --- a/src/runtime/setup.rs +++ b/src/runtime/setup.rs @@ -244,9 +244,9 @@ impl Controller { 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); @@ -265,9 +265,9 @@ impl Controller { 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 } }]