From: Christopher Baines <mail@cbaines.net>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 67245@debbugs.gnu.org
Subject: [bug#67245] [PATCH] store: Use a non-blocking socket for store connections.
Date: Mon, 27 Nov 2023 09:48:09 +0000 [thread overview]
Message-ID: <875y1nmrwf.fsf@cbaines.net> (raw)
In-Reply-To: <87fs0s17op.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 2006 bytes --]
Ludovic Courtès <ludo@gnu.org> writes:
> Hi Christopher,
>
> Christopher Baines <mail@cbaines.net> skribis:
>
>> For some applications, it's important to do this here rather than just making
>> the socket non-blocking after the connection is established because there can
>> be I/O on the socket that will block during the handshake.
>>
>> I've noticed this blocking during the handshake causing issues in the build
>> coordinator for example.
>>
>> * guix/store.scm (open-unix-domain-socket, open-inet-socket): Pass
>> SOCK_NONBLOCK when calling socket.
>>
>> Change-Id: I8225762b78448bc1f7b698c8de5d736e13f577bf
>
> I feel we should really discuss on Guix + Fibers since we’ve apparently
> been going through the exact same set of issues. :-)
>
> (The other thing that comes to mind is the resource pool!)
I'm mostly ignoring these issues then coping the code once you write it
:)
>> +++ b/guix/store.scm
>> @@ -460,7 +460,9 @@ (define (open-unix-domain-socket file)
>> '&store-connection-error' upon error."
>> (let ((s (with-fluids ((%default-port-encoding #f))
>> ;; This trick allows use of the `scm_c_read' optimization.
>> - (socket PF_UNIX (logior SOCK_STREAM SOCK_CLOEXEC) 0)))
>> + (socket PF_UNIX
>> + (logior SOCK_STREAM SOCK_CLOEXEC SOCK_NONBLOCK)
>> + 0)))
>
> We cannot do this here because callers have to be prepared to deal with
> non-blocking sockets, and that’s not the case in Guix itself.
I can see potential problems for programs outside of Guix which use
suspendable ports, but given Guix doesn't use suspendable ports, this
won't change behaviour, right?
Obviously Guile will be working a bit differently, using poll when it
needs to wait for I/O, but at the scheme level within Guix, things
should be no different.
I tried guix weather with this change, and things seemed fine. Is there
a specific bit of Guix you're concerned about?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 987 bytes --]
next prev parent reply other threads:[~2023-11-27 10:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-17 18:05 [bug#67245] [PATCH] store: Use a non-blocking socket for store connections Christopher Baines
2023-11-26 22:16 ` Ludovic Courtès
2023-11-27 9:48 ` Christopher Baines [this message]
2023-11-30 21:11 ` Ludovic Courtès
2024-05-12 17:38 ` Christopher Baines
2024-05-11 16:53 ` [bug#67245] [PATCH v2] store: Add with-store/non-blocking Christopher Baines
2024-05-13 12:44 ` Ludovic Courtès
2024-05-13 19:32 ` bug#67245: " Christopher Baines
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875y1nmrwf.fsf@cbaines.net \
--to=mail@cbaines.net \
--cc=67245@debbugs.gnu.org \
--cc=ludo@gnu.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://git.savannah.gnu.org/cgit/guix.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).