diff --git a/src/runtime2/component/component.rs b/src/runtime2/component/component.rs index 962841d303fbecfe98385fc1f3479cf172042d11..b0dcb7df048c83f40ec96f54b1d9ab7b7e817eb9 100644 --- a/src/runtime2/component/component.rs +++ b/src/runtime2/component/component.rs @@ -908,8 +908,8 @@ pub(crate) fn special_create_component( // Transfer messages and link instantiator to created component for pair in port_pairs.iter() { instantiator_ctx.change_port_peer(sched_ctx, pair.instantiator_handle, None); - instantiator_ctx.remove_port(pair.instantiator_handle); transfer_messages(inbox_main, inbox_backup, pair, instantiator_ctx, created_ctx, created_component.as_mut()); + instantiator_ctx.remove_port(pair.instantiator_handle); let created_port_info = created_ctx.get_port(pair.created_handle); if pair.is_open && created_port_info.peer_comp_id == instantiator_ctx.id { @@ -1075,8 +1075,8 @@ pub(crate) fn perform_create_component( // Transferring the messages and removing the port from the // instantiator component instantiator_ctx.change_port_peer(sched_ctx, pair.instantiator_handle, None); - instantiator_ctx.remove_port(pair.instantiator_handle); transfer_messages(inbox_main, inbox_backup, pair, instantiator_ctx, created_ctx, created_component.as_mut()); + instantiator_ctx.remove_port(pair.instantiator_handle); // Here we take care of the case where the instantiator previously owned // both ends of the channel, but has transferred one port to the new diff --git a/src/runtime2/tests/internet.rs b/src/runtime2/tests/internet.rs index cdaf8c287383d4fe369d3bd8c7e7de4f6fa5843f..246726d62cd982b04b85ee5f814e15aff5203926 100644 --- a/src/runtime2/tests/internet.rs +++ b/src/runtime2/tests/internet.rs @@ -17,7 +17,7 @@ fn test_stdlib_file() { }); } - comp fake_socket(in cmds, out tx) { + comp fake_socket(in cmds, out tx) { auto to_send = {}; auto shutdown = false; @@ -26,14 +26,14 @@ fn test_stdlib_file() { sync { while (keep_going) { auto cmd = get(cmds); - if (let inet::Cmd::Send(data) = cmd) { + if (let inet::ClientCmd::Send(data) = cmd) { to_send = data; keep_going = false; - } else if (let inet::Cmd::Receive = cmd) { + } else if (let inet::ClientCmd::Receive = cmd) { put(tx, to_send); - } else if (let inet::Cmd::Finish = cmd) { + } else if (let inet::ClientCmd::Finish = cmd) { keep_going = false; - } else if (let inet::Cmd::Shutdown = cmd) { + } else if (let inet::ClientCmd::Shutdown = cmd) { keep_going = false; shutdown = true; } @@ -43,16 +43,16 @@ fn test_stdlib_file() { } comp fake_client(inet::TcpConnection conn) { - sync put(conn.tx, inet::Cmd::Send({1, 3, 3, 7})); + sync put(conn.tx, inet::ClientCmd::Send({1, 3, 3, 7})); sync { - put(conn.tx, inet::Cmd::Receive); + put(conn.tx, inet::ClientCmd::Receive); auto val = get(conn.rx); while (val[0] != 1 || val[1] != 3 || val[2] != 3 || val[3] != 7) { print(\"this is going very wrong\"); } - put(conn.tx, inet::Cmd::Finish); + put(conn.tx, inet::ClientCmd::Finish); } - sync put(conn.tx, inet::Cmd::Shutdown); + sync put(conn.tx, inet::ClientCmd::Shutdown); } comp constructor() { diff --git a/src/runtime2/tests/mod.rs b/src/runtime2/tests/mod.rs index 110d7de0d7e3fb8ed0d9d2d13e2e15c271a6e5c0..493bb3c46ee383e5ce2fb327a85bf7eec90af413 100644 --- a/src/runtime2/tests/mod.rs +++ b/src/runtime2/tests/mod.rs @@ -166,17 +166,17 @@ fn test_tcp_socket_http_request() { let _pd = ProtocolDescription::parse(b" import std.internet::*; - comp requester(out cmd_tx, in data_rx) { + comp requester(out cmd_tx, in data_rx) { print(\"*** TCPSocket: Sending request\"); sync { - put(cmd_tx, Cmd::Send(b\"GET / HTTP/1.1\\r\\n\\r\\n\")); + put(cmd_tx, ClientCmd::Send(b\"GET / HTTP/1.1\\r\\n\\r\\n\")); } print(\"*** TCPSocket: Receiving response\"); auto buffer = {}; auto done_receiving = false; sync while (!done_receiving) { - put(cmd_tx, Cmd::Receive); + put(cmd_tx, ClientCmd::Receive); auto data = get(data_rx); buffer @= data; @@ -201,7 +201,7 @@ fn test_tcp_socket_http_request() { c5 == cast('m') && c6 == cast('l') && c7 == cast('>') ) { print(\"*** TCPSocket: Detected \"); - put(cmd_tx, Cmd::Finish); + put(cmd_tx, ClientCmd::Finish); done_receiving = true; } } @@ -211,7 +211,7 @@ fn test_tcp_socket_http_request() { print(\"*** TCPSocket: Requesting shutdown\"); sync { - put(cmd_tx, Cmd::Shutdown); + put(cmd_tx, ClientCmd::Shutdown); } } @@ -224,7 +224,7 @@ fn test_tcp_socket_http_request() { ").expect("compilation"); // This test is disabled because it performs a HTTP request to google. - // let rt = Runtime::new(1, true, pd).unwrap(); + // let rt = Runtime::new(1, LOG_LEVEL, _pd).unwrap(); // create_component(&rt, "", "main", no_args()); } diff --git a/std/std.internet.pdl b/std/std.internet.pdl index d61d81535897752b94d57a1e51e2aea85b9eecb7..39a900e563f33ffb9fe2e72d1ab6b94bef02b5e9 100644 --- a/std/std.internet.pdl +++ b/std/std.internet.pdl @@ -7,7 +7,7 @@ union ClientCmd { Shutdown, } -comp tcp_client(u8[] ip, u16 port, in cmds, out rx) { +comp tcp_client(u8[] ip, u16 port, in cmds, out rx) { #builtin } @@ -17,7 +17,7 @@ union ListenerCmd { } struct TcpConnection { - out tx, + out tx, in rx, }