patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Alyssa Ross <hi@alyssa.is>
To: devel@spectrum-os.org
Cc: Cole Helbling <cole.e.helbling@outlook.com>
Subject: [PATCH ucspi-vsock] vsock_accept: return fd instead of 0 on success
Date: Wed, 10 Mar 2021 20:45:16 +0000	[thread overview]
Message-ID: <20210310204516.20041-1-hi@alyssa.is> (raw)

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].

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

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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10 20:45 Alyssa Ross [this message]
2021-03-10 20:48 ` Cole Helbling

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=20210310204516.20041-1-hi@alyssa.is \
    --to=hi@alyssa.is \
    --cc=cole.e.helbling@outlook.com \
    --cc=devel@spectrum-os.org \
    /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).