From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 9C8D5385841E for ; Mon, 8 Nov 2021 17:04:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9C8D5385841E Received: by mail-oi1-x234.google.com with SMTP id be32so6239877oib.11 for ; Mon, 08 Nov 2021 09:04:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=9Ej/0b7nYCGfRryJqGpkypKIZHYbA57smeHW4vryPVo=; b=LnTgRCJFAmQub/xDPAScb8t8/txX79hpdwY/HxjPjviNf8THQCqlg7OoEZXaZCczOJ jrgdSygCG683+FXgLJeBbCNhF2HFQLJXQpGy0FCCF5UDlqJAP30MpnQNIvyuBpXlhhCb 05S+1r68HmvzCcxi2wgnz/yb7wBteu+CPhCmF1191lomC4wg82CgUy0lbUIS9QK7j8B4 zbUN+mpnyKkTTZWPr/t+CwzinwJ3vSkG2jqO/P+ZamYO6voT38XZAn5vvaS2bYmRmsic LqahAt0RNFolrFLymOndlCbSdFCSpgYciatVrG6ZTYENejvRl4yAypf3GuVwp/czikrz JY4Q== X-Gm-Message-State: AOAM5315xQiTWgk9SsjVIPDdEB49xha8Xvb5puYxIWk8Yux57SmZHjig j2+MANNZpF3jZI4xa/QZMwtoSHCLtlfNQA== X-Google-Smtp-Source: ABdhPJzdLcRClDjM5z7wCB8AgBhlh3/A4i78aZpc85l0Yfkzl9DyypFHCSryKvirgHrEu7na1tb0Ww== X-Received: by 2002:a05:6808:2310:: with SMTP id bn16mr12528879oib.175.1636391065925; Mon, 08 Nov 2021 09:04:25 -0800 (PST) Received: from ?IPV6:2804:431:c7cb:55a:c067:29b:4c08:be99? ([2804:431:c7cb:55a:c067:29b:4c08:be99]) by smtp.gmail.com with ESMTPSA id p14sm5659460oov.0.2021.11.08.09.04.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Nov 2021 09:04:25 -0800 (PST) Message-ID: <5b49a1a1-9bb3-a564-b1b8-80a5a6570900@linaro.org> Date: Mon, 8 Nov 2021 14:04:23 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [PATCH] io: Refactor close_range and closefrom Content-Language: en-US To: Sergey Bugaev Cc: libc-alpha@sourceware.org, Samuel Thibault References: <20211108135800.2189664-1-adhemerval.zanella@linaro.org> <2485e81c-157e-37c5-317b-6f16fae8f211@linaro.org> From: Adhemerval Zanella In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Nov 2021 17:04:29 -0000 On 08/11/2021 12:13, Sergey Bugaev wrote: > On Mon, Nov 8, 2021 at 5:55 PM Adhemerval Zanella > wrote: >>> Is this (either closes everything or nothing) an appropriate thing to >>> promise in the common header? Similarly, if the default implementation >>> accepts no flags, should the common description mention "the >>> CLOSE_RANGE prefix"? >> >> Well, that's the semantic of the both the syscall and the Linux fallback. >> If Hurd does not provide such semantic I think you should work this out. > > My Hurd patch does provide that semantic. I'm concerned about this > being promised in the generic header; some other port/kernel could > potentially decide to instead stop & propagate an error from closing a > descriptor. Perhaps the claim could be qualified (for instance, "In > all current ports, ...")? Not that this matters. I think it worth to align with other two current implementation (Linux and FreeBSD) where errors are indeed ignored. I changed to: /* Close all file descriptors in the range FD up to MAX_FD. The flag FLAGS are defined by the CLOSE_RANGE prefix. This function behaves like close on the range and gaps where the file descriptor is invalid or errors encountered while closing file descriptors are ignored. Returns 0 on successor or -1 for failure (and sets errno accordingly). */ > > Another suggestion: > >> + for (int i = 0; i < maxfd; i++) >> + if (i >= lowfd) >> + __close_nocancel_nostatus (i); > > This should be > > int i; > for (i = first; i <= last && i < maxfd; i++) > __close_nocancel_nostatus (i); > > shouldn't it? > > How does that even compile? 'lowfd' is the name of closefrom's > argument. close_range's arguments are 'first' and 'last' (and > 'flags'). It does not, mostly because it is not really used anywhere. I have fixed it, thanks.