From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id IAR9CS/EY2VdJgAA9RJhRA:P1 (envelope-from ) for ; Sun, 26 Nov 2023 23:18:23 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id IAR9CS/EY2VdJgAA9RJhRA (envelope-from ) for ; Sun, 26 Nov 2023 23:18:23 +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 BB41E32BD1 for ; Sun, 26 Nov 2023 23:18:22 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=JNivdy7H; 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"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1701037103; 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=EIoodbFrlykBpqlgECvTW/T9LgKMfswp2BhPBjiMboc=; b=YIGBAicrrlxwA1tUP2rbYN1Jn/eIemVfTgyfCfEfsbqXPaHtodEPF2uEM6PkQAVnOT1Y6E qvmnlGWlZy30uXl29qVU4YyNdvR/kBLGNKitq+U8YBqB8b9nwDUdzQ5wqzGmCVrRI2BQ2y MgkVBsb25WvadLuF/vfFSBqo8ARs0xjCxlwWG6v+Y9eQCXhU3BipmVM7uNJMtn1MgiiVaF MAsIM22WGdu7F7R0Fh5XVj/L7VK68tG6Z1W+14r9xLKELI2JxF+X0cA4FJ7XmPqxBrIQx+ o4F6mF0CForM1qYexQeKbmHzqakkVx0v0uRRPXE0hQpa26+fUcKUfO1lwfncTw== 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=JNivdy7H; 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"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1701037103; a=rsa-sha256; cv=none; b=FRoJIcyjHLDgxPqTRkBa4WadVus9wuopoBDKUrJBj8JOWplTV5rFBUv7VHZ5o0AVq4mqx3 yWpdu8G4AjoHrQyB8jAQjPXM05vtxJ5z1xwML8hfH72VqhCqGFd4bIbG2lbRp3X3wlgZUm XlxktECQaVh3+aC535JZEcqmn4Q3i9Y41/oKT4vlVhx7z9msn1WHydTYjUuEt0b127ixCW Kz4PyzMZOmcOIN+geOjQ/uc7aL3baw62rIuf4iaby4/G00EzVOxNGVDdGcvyu6pM0TYunz kxSIvz5p+uVI87/CWnhMN9CICHhEsCZAe2ePLzXjAwrkIeH9x7zDpkLJhgZf4A== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r7NRt-0006bD-TX; Sun, 26 Nov 2023 17:17:57 -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 1r7NRs-0006az-58 for guix-patches@gnu.org; Sun, 26 Nov 2023 17:17:56 -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 1r7NRr-0005nM-TJ for guix-patches@gnu.org; Sun, 26 Nov 2023 17:17:55 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r7NRx-00058C-PF for guix-patches@gnu.org; Sun, 26 Nov 2023 17:18:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67245] [PATCH] store: Use a non-blocking socket for store connections. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 26 Nov 2023 22:18:01 +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.170103704019675 (code B ref 67245); Sun, 26 Nov 2023 22:18:01 +0000 Received: (at 67245) by debbugs.gnu.org; 26 Nov 2023 22:17:20 +0000 Received: from localhost ([127.0.0.1]:42813 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7NRH-00057G-QP for submit@debbugs.gnu.org; Sun, 26 Nov 2023 17:17:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45842) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7NRF-000571-DJ for 67245@debbugs.gnu.org; Sun, 26 Nov 2023 17:17:18 -0500 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 1r7NR3-0005kp-60; Sun, 26 Nov 2023 17:17:05 -0500 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=EIoodbFrlykBpqlgECvTW/T9LgKMfswp2BhPBjiMboc=; b=JNivdy7H6ADrs3dMAva3 eJSTy8Shl8gB1uzlDYJuhlITrsooCZC4SQZ16/VdF+vHF1jAwdaScySz79wyT0lza3KZEJpVXGhDP E80s6C+0ZWYGuT1akgUDbx0sdJSt6EisG7lWthGoJ0Hznwi00tW4fBB9qfefcRIuDUUPM6mUA0GQ9 5lHdtKF82L/z2YSAfMlDgCXtBisLvCraBYTlC0EacCGy0Y5ZnOn9SeCQuSqeg38Vgj7kKemelwvTA /9/Mg+OqmK//IGemsb/V2JSRcOgeF8ZhW/sYWs+L66lA5ksVLHotnbtFgrxcRCj/kzmSaSKZRAVdI dJOyKDAWrFVlmQ==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= In-Reply-To: <460cdfa67b473ea2f1593668b2d9d0fd159378d0.1700244314.git.mail@cbaines.net> (Christopher Baines's message of "Fri, 17 Nov 2023 18:05:14 +0000") References: <460cdfa67b473ea2f1593668b2d9d0fd159378d0.1700244314.git.mail@cbaines.net> Date: Sun, 26 Nov 2023 23:16:54 +0100 Message-ID: <87fs0s17op.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-Queue-Id: BB41E32BD1 X-Spam-Score: -5.06 X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -5.06 X-TUID: n+4+bKhrdxDH Hi Christopher, Christopher Baines skribis: > For some applications, it's important to do this here rather than just ma= king > 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 bui= ld > 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=E2=80=99ve appare= ntly been going through the exact same set of issues. :-) (The other thing that comes to mind is the resource pool!) > +++ 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=E2=80=99s not the case in Guix itself. In Cuirass, I have this: --8<---------------cut here---------------start------------->8--- (define (non-blocking-port port) "Make PORT non-blocking and return it." (let ((flags (fcntl port F_GETFL))) (when (zero? (logand O_NONBLOCK flags)) (fcntl port F_SETFL (logior O_NONBLOCK flags))) port)) (define (ensure-non-blocking-store-connection store) "Mark the file descriptor that backs STORE, a , as O_NONBLOCK." (match (store-connection-socket store) ((? file-port? port) (non-blocking-port port)) (_ #f))) (define-syntax-rule (with-store/non-blocking store exp ...) "Like 'with-store', bind STORE to a connection to the store, but ensure t= hat said connection is non-blocking (O_NONBLOCK). Evaluate EXP... in that context." (with-store store (ensure-non-blocking-store-connection store) (let () exp ...))) --8<---------------cut here---------------end--------------->8--- Then =E2=80=98with-store/non-blocking=E2=80=99 is used in fiberized context= where I know this is fine. I think it=E2=80=99ll have to remain this way until Guix itself is fiberize= d or something. Does that make sense? Ludo=E2=80=99.