From patchwork Fri Nov 17 18:05:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 56588 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 89EE527BBEA; Fri, 17 Nov 2023 18:06:25 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 861F827BBE2 for ; Fri, 17 Nov 2023 18:06:21 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r43EF-0006tF-3a; Fri, 17 Nov 2023 13:06:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r43EC-0006sw-TT for guix-patches@gnu.org; Fri, 17 Nov 2023 13:06:04 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r43EB-0000ji-ST; Fri, 17 Nov 2023 13:06:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r43E9-00085k-Ou; Fri, 17 Nov 2023 13:06:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67245] [PATCH] store: Use a non-blocking socket for store connections. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Fri, 17 Nov 2023 18:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 67245 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 67245@debbugs.gnu.org Cc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by submit@debbugs.gnu.org id=B.170024433631067 (code B ref -1); Fri, 17 Nov 2023 18:06:01 +0000 Received: (at submit) by debbugs.gnu.org; 17 Nov 2023 18:05:36 +0000 Received: from localhost ([127.0.0.1]:47108 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r43Dj-000851-T2 for submit@debbugs.gnu.org; Fri, 17 Nov 2023 13:05:36 -0500 Received: from lists.gnu.org ([2001:470:142::17]:39432) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r43Dh-00084l-Kv for submit@debbugs.gnu.org; Fri, 17 Nov 2023 13:05:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r43Db-0006kN-O9 for guix-patches@gnu.org; Fri, 17 Nov 2023 13:05:27 -0500 Received: from mira.cbaines.net ([2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r43DV-0000ZB-3w for guix-patches@gnu.org; Fri, 17 Nov 2023 13:05:27 -0500 Received: from localhost (unknown [217.155.61.229]) by mira.cbaines.net (Postfix) with ESMTPSA id B1DA227BBE2 for ; Fri, 17 Nov 2023 18:05:15 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id fbe70812 for ; Fri, 17 Nov 2023 18:05:14 +0000 (UTC) From: Christopher Baines Date: Fri, 17 Nov 2023 18:05:14 +0000 Message-ID: <460cdfa67b473ea2f1593668b2d9d0fd159378d0.1700244314.git.mail@cbaines.net> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27; envelope-from=mail@cbaines.net; helo=mira.cbaines.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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 --- guix/store.scm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) base-commit: e35b7c5386c1bfacf47ed31bac9b503373dd26fc diff --git a/guix/store.scm b/guix/store.scm index f8e77b2cd9..216be98c05 100644 --- a/guix/store.scm +++ 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))) (a (make-socket-address PF_UNIX file))) (system-error-to-connection-error file @@ -488,7 +490,8 @@ (define (open-inet-socket host port) ((ai rest ...) (let ((s (socket (addrinfo:fam ai) ;; TCP/IP only - (logior SOCK_STREAM SOCK_CLOEXEC) IPPROTO_IP))) + (logior SOCK_STREAM SOCK_CLOEXEC SOCK_NONBLOCK) + IPPROTO_IP))) (catch 'system-error (lambda ()