patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: "Cole Helbling" <cole.e.helbling@outlook.com>
To: "Alyssa Ross" <hi@alyssa.is>, <devel@spectrum-os.org>
Cc: Cole Helbling <cole.e.helbling@outlook.com>
Subject: Re: [PATCH ucspi-vsock] vsock_accept: return fd instead of 0 on success
Date: Wed, 10 Mar 2021 12:48:03 -0800	[thread overview]
Message-ID: <SJ0PR03MB55815F8D8C001E77C83C2F33B3919@SJ0PR03MB5581.namprd03.prod.outlook.com> (raw)
In-Reply-To: <20210310204516.20041-1-hi@alyssa.is>

On Wed Mar 10, 2021 at 12:45 PM PST, Alyssa Ross wrote:
> This would result in the spawned process being hooked up to stdin,
> instead of the vsock. Then stdin would be closed, so subsequent
> processes would be connected to nothing. Oops.
>
> ---
> I am... a bit embarassed that I didn't notice this after already
> fixing the exact same problem in vsock_connect[1].

Technically, you _did_ notice this after fixing the the problem in
vsock_connect -- just not immediately / at the same time ;)

> Maybe I can write an integration test that runs vsockserver and
> vsockclient and checks they actually do the right thing...
>
> [1]:
> https://spectrum-os.org/lists/archives/spectrum-devel/20210309171816.8589-1-hi@alyssa.is/raw
>
> vsock.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/vsock.c b/vsock.c
> index d9ff3b6..e6a173c 100644
> --- a/vsock.c
> +++ b/vsock.c
> @@ -32,14 +32,15 @@ int vsock_accept(int sockfd, uint32_t *cid, uint32_t
> *port)
> {
> struct sockaddr_vm addr = { 0 };
> socklen_t addr_size = sizeof addr;
> + int fd;
>  
> - if (accept(sockfd, (struct sockaddr *)&addr, &addr_size) == -1)
> + if ((fd = accept(sockfd, (struct sockaddr *)&addr, &addr_size)) == -1)
> return -1;
>  
> *cid = addr.svm_cid;
> *port = addr.svm_port;
>  
> - return 0;
> + return fd;
> }
>  
> int vsock_connect(int fd, uint32_t cid, uint32_t port)
> --
> 2.30.0

Reviewed-by: Cole Helbling <cole.e.helbling@outlook.com>

      reply	other threads:[~2021-03-10 20:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10 20:45 Alyssa Ross
2021-03-10 20:48 ` Cole Helbling [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=SJ0PR03MB55815F8D8C001E77C83C2F33B3919@SJ0PR03MB5581.namprd03.prod.outlook.com \
    --to=cole.e.helbling@outlook.com \
    --cc=devel@spectrum-os.org \
    --cc=hi@alyssa.is \
    /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).