From 3474c19309b4e1f6c3c2b16f6834b5394a21c29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Paraniak?= Date: Fri, 10 Oct 2025 14:13:07 +0800 Subject: [PATCH 1/2] conn: do not close the channel upon read EOF Conn protocol closes the channel as soon as an EOF is received from a read request. This is at odds with a typical usage of conn, where separate programs are used to send a command and receive a result. We modify this behavior by calling moat `bal_f` only on genuine read errors. Furthermore, in conn.c we close the channel after processing the effect if we detect that the read end of the pipe has closed. --- pkg/vere/io/conn.c | 5 +++++ pkg/vere/newt.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/vere/io/conn.c b/pkg/vere/io/conn.c index cd0cfc3c66..d1fc1b0f37 100644 --- a/pkg/vere/io/conn.c +++ b/pkg/vere/io/conn.c @@ -699,6 +699,7 @@ _conn_sock_cb(uv_stream_t* sem_u, c3_i tas_i) u3_chan* can_u; c3_i err_i; + can_u = c3_calloc(sizeof(u3_chan)); can_u->mor_u.ptr_v = can_u; can_u->mor_u.pok_f = _conn_moor_poke; @@ -866,6 +867,10 @@ _conn_ef_handle(u3_conn* con_u, can_u->mor_u.bal_f(can_u, -4, "handle-unknown"); u3_king_bail(); } + + if ( !uv_is_readable((uv_stream_t*)&con_u->san_u->pyp_u) ) { + _conn_close_chan(con_u->san_u, can_u); + } } else { u3l_log("conn: handle-no-coq %" PRIx32 " %" PRIu32, diff --git a/pkg/vere/newt.c b/pkg/vere/newt.c index 40bfcff70e..43707f811b 100644 --- a/pkg/vere/newt.c +++ b/pkg/vere/newt.c @@ -179,9 +179,9 @@ _newt_read_cb(uv_stream_t* str_u, if ( UV_EOF != len_i ) { fprintf(stderr, "newt: read failed %s\r\n", uv_strerror(len_i)); + mot_u->bal_f(mot_u->ptr_v, len_i, uv_strerror(len_i)); } - mot_u->bal_f(mot_u->ptr_v, len_i, uv_strerror(len_i)); } // EAGAIN/EWOULDBLOCK // From 31c7f680ab04dd231631889dcd5baaf110302427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Paraniak?= Date: Fri, 10 Oct 2025 14:19:12 +0800 Subject: [PATCH 2/2] conn: fix stray newline --- pkg/vere/io/conn.c | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/vere/io/conn.c b/pkg/vere/io/conn.c index d1fc1b0f37..12ed601bdd 100644 --- a/pkg/vere/io/conn.c +++ b/pkg/vere/io/conn.c @@ -699,7 +699,6 @@ _conn_sock_cb(uv_stream_t* sem_u, c3_i tas_i) u3_chan* can_u; c3_i err_i; - can_u = c3_calloc(sizeof(u3_chan)); can_u->mor_u.ptr_v = can_u; can_u->mor_u.pok_f = _conn_moor_poke;