diff --git a/test/test-udp-recv-in-a-row.c b/test/test-udp-recv-in-a-row.c index 30745def0f6..8b45c25b302 100644 --- a/test/test-udp-recv-in-a-row.c +++ b/test/test-udp-recv-in-a-row.c @@ -50,11 +50,15 @@ static void sv_recv_cb(uv_udp_t* handle, const uv_buf_t* rcvbuf, const struct sockaddr* addr, unsigned flags) { - if (++ recv_cnt < N) { - ASSERT_EQ(sizeof(send_data), nread); - } else { - ASSERT_OK(nread); - } + /* |nread| can be zero when the kernel drops an incoming datagram after + * marking the file descriptor as readable but before libuv has a chance + * to receive it. Libuv still invokes the uv_udp_recv_cb callback to give + * back the memory from the uv_alloc_cb callback. + * + * See https://github.com/libuv/libuv/issues/4219. + */ + ASSERT_GE(nread, 0); + recv_cnt++; } static void check_cb(uv_check_t* handle) {