From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id sDnoN7cTQmbB6AAAe85BDQ:P1 (envelope-from ) for ; Mon, 13 May 2024 15:20:56 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id sDnoN7cTQmbB6AAAe85BDQ (envelope-from ) for ; Mon, 13 May 2024 15:20:56 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=d95gHOCA; dmarc=pass (policy=none) header.from=gnu.org; 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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1715606455; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=2VGotPU8kBTI0EM7RpRUtSmAxu6IfrLuiOIXuDhyPLU=; b=FFnEp24fsqSixCcdp4Lcb9M4J9ij5G3KHs2xUH/LADU4wPLN/P8Imr6PXaK9Wmychd5v1I JF3jPJliERgX8GKTwDQLkOIJY9fAZC09y6TYFC8WmYgFQjFW4F7FyP9gxCVlVSHG+/E+ek W6KFVtveD0W5q8yQGiApSbcY0zN1zgW8P+zft/QXonSHzwpkqfugv+hs9QzZWTMhATOijJ FoWj3oyYIp2PnCnwbcVcem9t+gd4iA7vBzUc3QsGxvaebSkOVhYGDjztuJD+f+NOp81bWj TT+hPSs3Bezpf16Vs1ZEcWpLMuethIDG2eu0Mxz4cx/B4jB1hApc7zgZFW8NRA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1715606455; a=rsa-sha256; cv=none; b=UQt58ztop/UMIa1zcAE7/ohDJRgl4DbnBgGBqadN3GffnAheYK+GVdJ0WzMjvJZmbWWmEB ShTk/RDneoXtp0UsnesmRafRDjJCHj4rD+9CrfCbyFor6Kj44h3bVLnXF6MMw9VyBlswD7 m7NAp/tuYP6e+JPYmAoFvj9SKIesUuJOY+GOUR3szy5JYwXqYXfLMZ94j6SiIdo+ip1xg0 YsoawXnTK8nfZwfPhTueeltgvLryHsbdSkjf245wDUA5dFV0T/5Ry1DmnhCjpvtl7x68gR kDjQGquTqRy5L5V3NnfXJI0MUfiIH+ELSXD9de5K31gP6pcuzznip54xy9Ih/Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=d95gHOCA; dmarc=pass (policy=none) header.from=gnu.org; 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 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 A9CF84E9D for ; Mon, 13 May 2024 15:20:55 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s6V3I-0004GL-QK; Mon, 13 May 2024 08:45:12 -0400 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 1s6V39-0004Do-O8 for guix-patches@gnu.org; Mon, 13 May 2024 08:45:05 -0400 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 1s6V38-00067Z-5d for guix-patches@gnu.org; Mon, 13 May 2024 08:45:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s6V38-0001DM-8e for guix-patches@gnu.org; Mon, 13 May 2024 08:45:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#67245] [PATCH v2] store: Add with-store/non-blocking. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 13 May 2024 12:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67245 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Christopher Baines Cc: Josselin Poiret , Simon Tournier , Mathieu Othacehe , Tobias Geerinckx-Rice , Ricardo Wurmus , 67245@debbugs.gnu.org, Christopher Baines Received: via spool by 67245-submit@debbugs.gnu.org id=B67245.17156042774638 (code B ref 67245); Mon, 13 May 2024 12:45:02 +0000 Received: (at 67245) by debbugs.gnu.org; 13 May 2024 12:44:37 +0000 Received: from localhost ([127.0.0.1]:60768 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s6V2i-0001Ck-Fh for submit@debbugs.gnu.org; Mon, 13 May 2024 08:44:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37206) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s6V2g-0001Ce-Co for 67245@debbugs.gnu.org; Mon, 13 May 2024 08:44:35 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s6V2Y-00061d-Gv; Mon, 13 May 2024 08:44:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=2VGotPU8kBTI0EM7RpRUtSmAxu6IfrLuiOIXuDhyPLU=; b=d95gHOCAkXdHMIyXa4cS GwD8spNbYK1kCULFvSJjIYWJLe5fpn2x1SZlhJ9uOX7azV6P5KCUulHwrXXs7uU7/UBCJyTvGJVz2 Riwf1LPTVOu0I633l8yUrAHh5npUE11sBKUKjDuroXu1T0jjRpZAFllJ1U77h7q3RamvTOQW6so5k +05Wt8h0qTFbGi2TP8ZdQ75zKvRAqgj8GzJSBO7RtK4SrwZAdJz6RerbDLf3yfcRNdpF/PE6NyOTf i+KGr8j4Nira3jgcWEjajekBhu65x5CQGmnueMnwfv/rd7cO4jmo4D6UQf0848c0ZxZKW6pLlpe88 6Si4sPNOv4nPsg==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= In-Reply-To: (Christopher Baines's message of "Sat, 11 May 2024 17:53:20 +0100") References: <460cdfa67b473ea2f1593668b2d9d0fd159378d0.1700244314.git.mail@cbaines.net> Date: Mon, 13 May 2024 14:44:18 +0200 Message-ID: <87seylankt.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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-Spam-Score: -2.77 X-Spam-Score: -2.77 X-Migadu-Queue-Id: A9CF84E9D X-Migadu-Scanner: mx11.migadu.com X-TUID: D79UFt0b/5rD Hi, Christopher Baines skribis: > For some applications, it's important to establish a non-blocking connect= ion > rather than just making the socket non-blocking after the connection is > established. This is because there is I/O on the socket that will block d= uring > the handshake. > > I've noticed this blocking during the handshake causing issues in the bui= ld > coordinator for example. > > This commit adds a new with-store variant to avoid changing the behaviour= of > with-store/open-connection to ensure that this change can't break anything > that depends on the blocking nature of the socket. > > * guix/store.scm (open-unix-domain-socket, open-inet-socket): Take > #:non-blocking? and use SOCK_NONBLOCK when calling socket if appropriate. > (connect-to-daemon, open-connection, call-with-store): Take #:non-blockin= g? > and pass it on. > (with-store/non-blocking): New syntax rule. > > Change-Id: I8225762b78448bc1f7b698c8de5d736e13f577bf [...] > +(define* (open-unix-domain-socket file #:key non-blocking?) > "Connect to the Unix-domain socket at FILE and return it. Raise a > -'&store-connection-error' upon error." > +'&store-connection-error' upon error. If NON-BLOCKING?, make the socket > +non-blocking." > (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))) Make sure SOCK_NONBLOCK is added only when =E2=80=98non-blocking?=E2=80=99 = is true. > +(define-syntax-rule (with-store/non-blocking store exp ...) > + "Bind STORE to an non-blocking open connection to the store and evalua= te > +EXPs; automatically close the store when the dynamic extent of EXP is le= ft." > + (call-with-store (lambda (store) exp ...) #:non-blocking? #t)) I think we=E2=80=99ll need an entry in =E2=80=98.dir-locals.el=E2=80=99 and= one in (guix read-print) for proper formatting. OK for me with these changes! Thanks, Ludo=E2=80=99.