Skip to content

Commit a1aa075

Browse files
authored
conn: optionally deliver channel response after EOF on read (#981)
Includes and supersedes #892, ensuring no behavior change for mars/urth IPC pipe.
2 parents 82d4248 + bcb965a commit a1aa075

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

pkg/vere/io/conn.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ _conn_sock_cb(uv_stream_t* sem_u, c3_i tas_i)
704704
can_u->mor_u.ptr_v = can_u;
705705
can_u->mor_u.pok_f = _conn_moor_poke;
706706
can_u->mor_u.bal_f = _conn_moor_bail;
707+
can_u->mor_u.fag_w = 1; // XX cleanup, nonzero means ignore EOF
707708
can_u->coq_l = san_u->nex_l++;
708709
can_u->san_u = san_u;
709710
err_i = uv_timer_init(u3L, &can_u->mor_u.tim_u);
@@ -867,6 +868,10 @@ _conn_ef_handle(u3_conn* con_u,
867868
can_u->mor_u.bal_f(can_u, -4, "handle-unknown");
868869
u3_king_bail();
869870
}
871+
872+
if ( !uv_is_readable((uv_stream_t*)&con_u->san_u->pyp_u) ) {
873+
_conn_close_chan(con_u->san_u, can_u);
874+
}
870875
}
871876
else {
872877
u3l_log("conn: handle-no-coq %" PRIx32 " %" PRIu32,

pkg/vere/newt.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,12 @@ _newt_read_cb(uv_stream_t* str_u,
179179

180180
if ( UV_EOF != len_i ) {
181181
fprintf(stderr, "newt: read failed %s\r\n", uv_strerror(len_i));
182+
mot_u->bal_f(mot_u->ptr_v, len_i, uv_strerror(len_i));
183+
}
184+
else if ( !mot_u->fag_w ) {
185+
mot_u->bal_f(mot_u->ptr_v, len_i, uv_strerror(len_i));
182186
}
183187

184-
mot_u->bal_f(mot_u->ptr_v, len_i, uv_strerror(len_i));
185188
}
186189
// EAGAIN/EWOULDBLOCK
187190
//

pkg/vere/vere.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
typedef struct _u3_moat {
9595
uv_pipe_t pyp_u; // input stream
9696
u3_moor_bail bal_f; // error response function
97+
c3_w fag_w;
9798
void* ptr_v; // callback pointer
9899
u3_moor_poke pok_f; // action function
99100
u3_mess mes_u; // message in progress
@@ -107,13 +108,15 @@
107108
typedef struct _u3_mojo {
108109
uv_pipe_t pyp_u; // output stream
109110
u3_moor_bail bal_f; // error response function
111+
c3_w fag_w;
110112
void* ptr_v; // callback pointer
111113
} u3_mojo;
112114

113115
/* u3_moor: two-way message stream, linked list */
114116
typedef struct _u3_moor {
115117
uv_pipe_t pyp_u; // duplex stream
116118
u3_moor_bail bal_f; // error response function
119+
c3_w fag_w;
117120
void* ptr_v; // callback pointer
118121
u3_moor_poke pok_f; // action function
119122
u3_mess mes_u; // message in progress

0 commit comments

Comments
 (0)