patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Alyssa Ross <hi@alyssa.is>
To: Yureka <yuka@yuka.dev>
Cc: devel@spectrum-os.org
Subject: Re: [PATCH] release/checks/integration: handle partial sends
Date: Sat, 29 Nov 2025 18:38:24 +0100	[thread overview]
Message-ID: <87ikesn3hr.fsf@alyssa.is> (raw)
In-Reply-To: <c3e21f4e-ec29-4329-8413-6d29e075e634@yuka.dev>

[-- Attachment #1: Type: text/plain, Size: 2998 bytes --]

Yureka <yuka@yuka.dev> writes:

> Thanks for looking into this.
>
> On 11/29/25 17:35, Alyssa Ross wrote:
>> Sometimes we see a test failure that looks like this:
>>
>> unexpected connection data: qemu-system-aarch64: terminating on signal 
>> 15 from pid 184 ()
>>
>> I think this is because, now that the nc command in the networking
>> integration test has a timeout, it's possible for it to time out after
>> having opened the connection, but before having written all its input
>> to it. Therefore, ignore connections that send a prefix of the
>> expected data (including nothing), and just wait for the next
>> connection rather than failing if that happens.
>>
>> Closes: 
>> https://spectrum-os.org/lists/archives/spectrum-devel/875xbl33vw.fsf@alyssa.is/
>> Fixes: c61b297 ("release/checks/integration: add nc timeout")
>> Signed-off-by: Alyssa Ross <hi@alyssa.is>
>> ---
>> Please test! It's difficult to know if I've solved the problem for
>> real, since it happens transiently.
>>
>> release/checks/integration/networking.c | 49 +++++++++++++++----------
>> 1 file changed, 30 insertions(+), 19 deletions(-)
>>
>> diff --git a/release/checks/integration/networking.c 
>> b/release/checks/integration/networking.c
>> index 97d7895..a445af1 100644
>> --- a/release/checks/integration/networking.c
>> +++ b/release/checks/integration/networking.c
>> @@ -57,32 +57,43 @@ static int setup_server(void)
>> static void expect_connection(int listener)
>> {
>> - int conn_fd;
>> - FILE *conn;
>> + int conn, r;
>> char msg[7];
>> size_t len;
>> - fputs("waiting for server connection\n", stderr);
>> - if ((conn_fd = accept(listener, nullptr, nullptr)) == -1) {
>> - perror("accept");
>> - exit(EXIT_FAILURE);
>> - }
>> - fputs("accepted connection!\n", stderr);
>> - if (!(conn = fdopen(conn_fd, "r"))) {
>> - perror("fdopen(server connection)");
>> - exit(EXIT_FAILURE);
>> - }
>> + for (;;) {
>> + len = 0;
>> - len = fread(msg, 1, sizeof msg, conn);
>> - if (len != 6 || memcmp("hello\n", msg, 6)) {
>> - if (ferror(conn))
>> - perror("fread(server connection)");
>> - else
>> + fputs("waiting for server connection\n", stderr);
>> + if ((conn = accept(listener, nullptr, nullptr)) == -1) {
>> + perror("accept");
>> + exit(EXIT_FAILURE);
>> + }
>> + fputs("accepted connection!\n", stderr);
>> +
>> + for (;;) {
>> + r = read(conn, msg + len, sizeof msg - len);
>> + if (r == -1) {
>> + perror("read");
>> + exit(EXIT_FAILURE);
>> + }
>> + if (r == 0)
>> + break;
>> + len += r;
>> + }
>> +
>> + if (memcmp("hello\n", msg, len) || len > 6) {
>> fprintf(stderr, "unexpected connection data: %.*s",
>> (int)len, msg);
>> - exit(EXIT_FAILURE);
>> + exit(EXIT_FAILURE);
>> + }
>> +
>> + // If connection was disconnect partway through, try again.
>> + if (len < 6)
>> + continue;
>> +
>> + return;
>> }
>> - fclose(conn);
>
> Is it intentional that the connection is never closed?

It is not, thanks!

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

      reply	other threads:[~2025-11-29 17:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-29 16:35 [PATCH] release/checks/integration: handle partial sends Alyssa Ross
2025-11-29 17:27 ` Yureka
2025-11-29 17:38   ` Alyssa Ross [this message]

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=87ikesn3hr.fsf@alyssa.is \
    --to=hi@alyssa.is \
    --cc=devel@spectrum-os.org \
    --cc=yuka@yuka.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.
Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).