diff --git a/repos/libports/run/netty.inc b/repos/libports/run/netty.inc index 56228300cc..0f4eb088a0 100644 --- a/repos/libports/run/netty.inc +++ b/repos/libports/run/netty.inc @@ -6,6 +6,7 @@ import_from_depot [depot_user]/src/[base_src] \ [depot_user]/src/dynamic_rom \ [depot_user]/src/init \ [depot_user]/src/libc \ + [depot_user]/src/stdcxx \ [depot_user]/src/nic_router \ [depot_user]/src/vfs_audit \ [depot_user]/src/vfs_lxip \ @@ -50,12 +51,12 @@ append config { - + - + - + @@ -96,7 +97,7 @@ append_if [use_dynamic_rom] config { - + @@ -156,4 +157,4 @@ append qemu_args " -nographic " append_qemu_nic_args "host=10.0.2.1,dhcpstart=10.0.2.55,hostfwd=tcp::10080-:80,hostfwd=tcp::18080-:8080,hostfwd=udp::10007-:7,hostfwd=udp::17070-:7070" -# vi: set ft=tcl : +# vi: set ft=tcl diff --git a/repos/libports/run/netty_lwip.inc b/repos/libports/run/netty_lwip.inc index e90d131ae8..f185a6865d 100644 --- a/repos/libports/run/netty_lwip.inc +++ b/repos/libports/run/netty_lwip.inc @@ -3,9 +3,9 @@ import_from_depot [depot_user]/src/[base_src] \ [depot_user]/pkg/[drivers_nic_pkg] \ [depot_user]/src/init \ [depot_user]/src/libc \ + [depot_user]/src/stdcxx \ [depot_user]/src/nic_router \ [depot_user]/src/vfs_audit \ - [depot_user]/src/vfs_lwip \ [depot_user]/src/vfs append config { @@ -27,10 +27,11 @@ append config { - + + - + @@ -51,12 +52,12 @@ append config { - + - + - + - - - @@ -112,6 +110,6 @@ append config { } append qemu_args " -nographic " -append_qemu_nic_args +append_qemu_nic_args "host=10.0.2.1,dhcpstart=10.0.2.55,hostfwd=tcp::10080-:80,hostfwd=tcp::18080-:8080,hostfwd=udp::10007-:7,hostfwd=udp::17070-:7070" # vi: set ft=tcl : diff --git a/repos/libports/run/netty_lwip_tcp.run b/repos/libports/run/netty_lwip_tcp.run index 3e5129c851..9984aee53e 100644 --- a/repos/libports/run/netty_lwip_tcp.run +++ b/repos/libports/run/netty_lwip_tcp.run @@ -1,8 +1,9 @@ source ${genode_dir}/repos/libports/run/netty_lwip.inc -build { test/netty/tcp } +build { lib/vfs_lwip test/netty/tcp } append config { + - - + + + @@ -58,7 +61,7 @@ append config { } install_config $config -build_boot_image { test-netty_tcp } +build_boot_image { vfs_lwip.lib.so test-netty_tcp } run_genode_until forever # vi: set ft=tcl : diff --git a/repos/libports/run/netty_lxip_tcp.run b/repos/libports/run/netty_lxip_tcp.run index 3c5c5f8fa0..cfd24cf099 100644 --- a/repos/libports/run/netty_lxip_tcp.run +++ b/repos/libports/run/netty_lxip_tcp.run @@ -3,6 +3,7 @@ source ${genode_dir}/repos/libports/run/netty.inc build { test/netty/tcp } append config { + - - + + diff --git a/repos/libports/src/test/netty/tcp/main.cc b/repos/libports/src/test/netty/tcp/main.cc index 4c15a07a56..8ea8a72566 100644 --- a/repos/libports/src/test/netty/tcp/main.cc +++ b/repos/libports/src/test/netty/tcp/main.cc @@ -13,7 +13,7 @@ /* Local includes */ #include - +#include namespace Netty { struct Tcp; } @@ -59,56 +59,69 @@ void Netty::Tcp::server(int const sd, bool const nonblock, bool const read_write Genode::log("okay, accept will not block"); } - Genode::log("test in ", nonblock ? "non-blocking" : "blocking", " mode"); + //Genode::log("test in ", nonblock ? "non-blocking" : "blocking", " mode"); int const cd = accept(sd, pcaddr, &scaddr); - Genode::log("cd=", cd); + //Genode::log("cd=", cd); if (cd == -1) DIE("accept"); - getnames(cd); + //getnames(cd); - size_t count = 0; - static char data[64*1024]; if (nonblock) nonblocking(cd); - while (true) { - int ret = read_write - ? read(cd, data, sizeof(data)) - : recv(cd, data, sizeof(data), 0); + auto con_handler = std::thread{[cd, read_write, nonblock]() + { + size_t count = 0; + static char data[64*1024]; + while (true) + { + //GENODE_LOG_TSC_NAMED(10, "netty_read"); + int ret = read_write + ? read(cd, data, sizeof(data)) + : recv(cd, data, sizeof(data), 0); - if (ret == 0) { - Genode::log("experienced EOF"); - break; - } + if (ret == 0) + { + // Genode::log("experienced EOF"); + break; + } - if (ret > 0) { - /* echo received data */ - ret = read_write - ? write(cd, data, ret) - : send(cd, data, ret, 0); - if (ret == -1) DIE(read_write ? "write" : "send"); + if (ret > 0) + { + //GENODE_LOG_TSC_NAMED(10, "netty_write"); + /* echo received data */ + ret = read_write + ? write(cd, data, ret) + : send(cd, data, ret, 0); + if (ret == -1) + DIE(read_write ? "write" : "send"); - count += ret; - continue; - } + count += ret; + continue; + } - if (!nonblock || errno != EAGAIN) - DIE(read_write ? "read" : "recv"); + if (!nonblock || errno != EAGAIN) + DIE(read_write ? "read" : "recv"); - Genode::log("block in select because of EAGAIN"); - fd_set read_fds; FD_ZERO(&read_fds); FD_SET(cd, &read_fds); - ret = select(cd + 1, &read_fds, nullptr, nullptr, nullptr); - if (ret == -1) DIE("select"); - } + Genode::log("block in select because of EAGAIN"); + fd_set read_fds; + FD_ZERO(&read_fds); + FD_SET(cd, &read_fds); + ret = select(cd + 1, &read_fds, nullptr, nullptr, nullptr); + if (ret == -1) + DIE("select"); - Genode::log("echoed ", count, " bytes"); + ret = shutdown(cd, SHUT_RDWR); + if (ret == -1) DIE("shutdown"); - ret = shutdown(cd, SHUT_RDWR); - if (ret == -1) DIE("shutdown"); + ret = close(cd); + if (ret == -1) DIE("close"); + } + }}; + con_handler.detach(); - ret = close(cd); - if (ret == -1) DIE("close"); + //Genode::log("echoed ", count, " bytes"); } } diff --git a/repos/libports/src/test/netty/tcp/target.mk b/repos/libports/src/test/netty/tcp/target.mk index 14113d8715..b330e810cf 100644 --- a/repos/libports/src/test/netty/tcp/target.mk +++ b/repos/libports/src/test/netty/tcp/target.mk @@ -1,6 +1,6 @@ TARGET = test-netty_tcp SRC_CC = main.cc netty.cc -LIBS = base libc +LIBS = base libc stdcxx INC_DIR += $(PRG_DIR)/..