From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id AIUsMJ2rV2WcygAA9RJhRA:P1 (envelope-from ) for ; Fri, 17 Nov 2023 19:06:21 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id AIUsMJ2rV2WcygAA9RJhRA (envelope-from ) for ; Fri, 17 Nov 2023 19:06:21 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 651703D93B for ; Fri, 17 Nov 2023 19:06:21 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1700244381; a=rsa-sha256; cv=none; b=X4vQiZIiRWbJOW8LwvM3T01k7RKQT+p7rYWMaPOKxfAVVlS1FxoB3VyAxRUKtDoq9WmjCR wgSJvPP8etY+Z+HcZZehmhF/JChw69FO9lVaHq9ibx78qU0+lHGl2p7zkuxNzU4EkfirT5 LWQsHXNZ7QSbLwgzmKfM73eHmxrJMUfeBJAm3rJS10OZqsRzU0BqGXIcNps31MjnmTTaTk kuyIl1+auTcmyl8bJh72+g8jg35Qn05zIep68ZWQJoVxHk4VzTxFkuFmy35hHqhnNloKaJ Nfn8FKFLjdXtD4jG1+bVovQVxcPmxeOIznV4AcDFdfCy55a618m0Ido98WvaPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1700244381; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=FLnSvis2FkK/XbsuOX30GVMg4nD1aZ26ASvWARiYREU=; b=jdlEP0RW1fFz9HOrqHttSElCZRg6gZ7jmG9B8lnGYntLgiV9OZ7tZFZO6cVn+xQovbYBcI pQIl6ZED5KyG8Gv+xkMv1DNqWAUNmu71Ft9NX1bp1TOWiNs2bQAo8SUNN98K9bZvNPmgDO aPviYn2Inl02o4RL3zJ+3tgF57XbmKtYtG3rT41jr5Gcxsn1cbpYGr2z7GddPvL5WhXXzh NPB5xu7BxuzFTJ69a+mAzukoz1qtVOGlkIBmU0XI40Qa9Z1vl/lIOQqOKq8P2Pea/DX4xM ExfT2ToiEAPUm3cAkRq1f0JMEDTw+6x06TyCH7fVdsnpuqVxvFe3uafHXSaMWQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" 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 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx11.migadu.com X-Spam-Score: -1.59 X-Migadu-Queue-Id: 651703D93B X-Migadu-Spam-Score: -1.59 X-TUID: eXn3nQ7nUESk 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(-) 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 () base-commit: e35b7c5386c1bfacf47ed31bac9b503373dd26fc -- 2.41.0