test: fix ipc_send_recv_pipe flakiness (#3478)

The read callback failed to handle the `nread == 0` case, which is rare
to non-existent on the systems we test on but apparently happens often
enough on Solaris on SPARC to draw attention.

Fixes #3469.
This commit is contained in:
Ben Noordhuis 2022-02-20 12:17:13 +01:00 committed by GitHub
parent 2bc22c40eb
commit e0a5f58d2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -308,8 +308,12 @@ static void read_cb(uv_stream_t* handle,
return; return;
} }
ASSERT_GE(nread, 0);
pipe = (uv_pipe_t*) handle; pipe = (uv_pipe_t*) handle;
do { ASSERT_EQ(pipe, &ctx2.channel);
while (uv_pipe_pending_count(pipe) > 0) {
if (++read_cb_count == 2) { if (++read_cb_count == 2) {
recv = &ctx2.recv; recv = &ctx2.recv;
write_req = &ctx2.write_req; write_req = &ctx2.write_req;
@ -318,10 +322,6 @@ static void read_cb(uv_stream_t* handle,
write_req = &ctx2.write_req2; write_req = &ctx2.write_req2;
} }
ASSERT(pipe == &ctx2.channel);
ASSERT(nread >= 0);
ASSERT(uv_pipe_pending_count(pipe) > 0);
pending = uv_pipe_pending_type(pipe); pending = uv_pipe_pending_type(pipe);
ASSERT(pending == UV_NAMED_PIPE || pending == UV_TCP); ASSERT(pending == UV_NAMED_PIPE || pending == UV_TCP);
@ -344,7 +344,7 @@ static void read_cb(uv_stream_t* handle,
&recv->stream, &recv->stream,
write2_cb); write2_cb);
ASSERT(r == 0); ASSERT(r == 0);
} while (uv_pipe_pending_count(pipe) > 0); }
} }
static void send_recv_start(void) { static void send_recv_start(void) {