From: Paolo Abeni <pabeni@redhat.com>
To: Stefano Garzarella <sgarzare@redhat.com>, netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux.dev
Subject: Re: [PATCH net-next 1/2] vsock/test: retry send() to avoid occasional failure in sigpipe test
Date: Tue, 13 May 2025 12:37:36 +0200 [thread overview]
Message-ID: <2c5581b9-c0a4-4620-ac82-0a98abfd4d0d@redhat.com> (raw)
In-Reply-To: <20250508142005.135857-2-sgarzare@redhat.com>
On 5/8/25 4:20 PM, Stefano Garzarella wrote:
> From: Stefano Garzarella <sgarzare@redhat.com>
>
> When the other peer calls shutdown(SHUT_RD), there is a chance that
> the send() call could occur before the message carrying the close
> information arrives over the transport. In such cases, the send()
> might still succeed. To avoid this race, let's retry the send() call
> a few times, ensuring the test is more reliable.
>
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
> tools/testing/vsock/vsock_test.c | 28 ++++++++++++++++++----------
> 1 file changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
> index d0f6d253ac72..7de870dee1cf 100644
> --- a/tools/testing/vsock/vsock_test.c
> +++ b/tools/testing/vsock/vsock_test.c
> @@ -1064,11 +1064,18 @@ static void test_stream_check_sigpipe(int fd)
>
> have_sigpipe = 0;
>
> - res = send(fd, "A", 1, 0);
> - if (res != -1) {
> - fprintf(stderr, "expected send(2) failure, got %zi\n", res);
> - exit(EXIT_FAILURE);
> - }
> + /* When the other peer calls shutdown(SHUT_RD), there is a chance that
> + * the send() call could occur before the message carrying the close
> + * information arrives over the transport. In such cases, the send()
> + * might still succeed. To avoid this race, let's retry the send() call
> + * a few times, ensuring the test is more reliable.
> + */
> + timeout_begin(TIMEOUT);
> + do {
> + res = send(fd, "A", 1, 0);
> + timeout_check("send");
> + } while (res != -1);
AFAICS the above could spin on send() for up to 10s, I would say
considerably more than 'a few times' ;)
In practice that could cause side effect on the timing of other
concurrent tests (due to one CPU being 100% used for a while).
What if the peer rcvbuf fills-up: will the send fail? That could cause
false-negative.
I *think* it should be better to insert a short sleep in the loop.
/P
next prev parent reply other threads:[~2025-05-13 10:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-08 14:20 [PATCH net-next 0/2] vsock/test: improve sigpipe test reliability Stefano Garzarella
2025-05-08 14:20 ` [PATCH net-next 1/2] vsock/test: retry send() to avoid occasional failure in sigpipe test Stefano Garzarella
2025-05-13 10:37 ` Paolo Abeni [this message]
2025-05-13 13:46 ` Stefano Garzarella
2025-05-08 14:20 ` [PATCH net-next 2/2] vsock/test: check also expected errno on " Stefano Garzarella
2025-05-13 10:41 ` Paolo Abeni
2025-05-13 13:49 ` Stefano Garzarella
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2c5581b9-c0a4-4620-ac82-0a98abfd4d0d@redhat.com \
--to=pabeni@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sgarzare@redhat.com \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®