Skip to content

Commit 74fa004

Browse files
committed
update tcp-echo-server.c and asio.c
- example `tcp-echo-server.c` buggy adding `yield()` to `stream_handler` function, will make example execute as expected in tls mode ** general bug/issue with `raii` future calls, libuv threading calls and openssl bio calls, will stale/hang, meaning never coro switch to another coroutine, the problem shows itself with `use_certificate` function **
1 parent 83da3bb commit 74fa004

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

examples/tcp-echo-server.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
void new_connection(uv_stream_t *socket) {
77
string data = stream_read(socket);
8-
printf(CLR_LN"%s\n", data);
98
if (data)
109
stream_write(socket, data);
1110
}
@@ -17,8 +16,8 @@ int uv_main(int argc, char **argv) {
1716
string_t host = is_secure ? "tls://127.0.0.1:%d" : "0.0.0.0:%d";
1817

1918
if (snprintf(addr, sizeof(addr), host, DEFAULT_PORT)) {
20-
//if (is_secure)
21-
// use_certificate(nullptr, 0);
19+
if (is_secure)
20+
use_certificate(nullptr, 0);
2221

2322
server = stream_bind(addr, 0);
2423
while (server) {

src/asio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,7 @@ static void_t stream_client(params_t args) {
14601460
uv_handle_set_data(handler(client), (void_t)uv->tls->uv_args);
14611461
defer((func_t)uv_arguments_free, uv->tls->uv_args);
14621462
defer(tls_close_free, uv->tls);
1463+
yield();
14631464
} else {
14641465
uv_handle_set_data(handler(client), nullptr);
14651466
defer(uv_close_free, client);

0 commit comments

Comments
 (0)