From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 3167E3858C2C for ; Mon, 8 Nov 2021 15:13:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3167E3858C2C Received: by mail-ot1-x330.google.com with SMTP id z2-20020a9d71c2000000b0055c6a7d08b8so13798514otj.5 for ; Mon, 08 Nov 2021 07:13:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2XDCeQ6EkNChBBgCbRRgguxK6u3Gye7bBzRUTPoL5SQ=; b=g+eFE4dElcwQqdsI1utdH0RDdOeHkf/MvdLhucBzA64v3TukCr955wwj1aeUkIpSKj Dw+bouMzLk5RBldRAUXAjBWEzohesW6D+fXyJFgAMRI0TzZjY+6zuVdVnQePxxGk4Gvc pEAc71wJ2YQqQr830EB13ksbys7Q4ojf6Pq7t9KkS4aSnG07pvNovtkMdyR47vGygVuF t60RUblpMAOpLArWmhETd2vS7LiAVGeyn3yuF4+bfXptZsBGcffzj6o8T4ZwomIIVK2o /yI4TrAmRYAEXIeWXoAqHT6DV9g4RXxSZ9Up0mr9jh6E5RUaTNz9icAVrJ9nDPgxTu9Y urMw== X-Gm-Message-State: AOAM5333q+BdXBNfLmg713oO4hLnk/gyZs5r+dgCb5KJ88Szvh76dWCG MuIEv6tL2S8xqGAeGMFQ4/X0gabxvzuUEClv+YrRbZNUCRScKvpY X-Google-Smtp-Source: ABdhPJxZ2Sy36hsT1QPrBZYRyUfW/FXwaKXjWQCyPwJaUL2BYBxbb/a6KAYz+fzoEs/Yup541Xtif4SPGYhPnH8a+f8= X-Received: by 2002:a05:6830:1356:: with SMTP id r22mr421955otq.196.1636384398574; Mon, 08 Nov 2021 07:13:18 -0800 (PST) MIME-Version: 1.0 References: <20211108135800.2189664-1-adhemerval.zanella@linaro.org> <2485e81c-157e-37c5-317b-6f16fae8f211@linaro.org> In-Reply-To: <2485e81c-157e-37c5-317b-6f16fae8f211@linaro.org> From: Sergey Bugaev Date: Mon, 8 Nov 2021 18:13:06 +0300 Message-ID: Subject: Re: [PATCH] io: Refactor close_range and closefrom To: Adhemerval Zanella Cc: libc-alpha@sourceware.org, Samuel Thibault Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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 15:13:20 -0000 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. 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'). Sergey