From: David Vrabel <david.vrabel@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
Ian Campbell <Ian.Campbell@eu.citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [PATCH] libxl: use libxl_fd_set_{cloexec, nonblock} helpers
Date: Mon, 28 Jul 2014 15:51:14 +0100 [thread overview]
Message-ID: <53D66362.8000901@citrix.com> (raw)
In-Reply-To: <53D60AB602000078000265E2@mail.emea.novell.com>
On 28/07/14 07:32, Jan Beulich wrote:
>>>> On 25.07.14 at 19:07, <Ian.Jackson@eu.citrix.com> wrote:
>> Jan Beulich writes ("[PATCH] libxl: use libxl_fd_set_{cloexec,nonblock}
>>> --- a/tools/libxl/libxl_qmp.c
>>> +++ b/tools/libxl/libxl_qmp.c
>>> @@ -358,19 +358,14 @@ static int qmp_open(libxl__qmp_handler *
>>> int timeout)
>> ...
>>> qmp->qmp_fd = socket(AF_UNIX, SOCK_STREAM, 0);
>> ...
>>> + ret = libxl_fd_set_nonblock(qmp->ctx, qmp->qmp_fd, 1);
>>> + if (ret) return -1;
>>
>> This change is correct.
>>
>>> ret = libxl_fd_set_cloexec(qmp->ctx, qmp->qmp_fd, 1);
>>> if (ret) return -1;
>>
>> But this (which you haven't touched) needs to be done with
>> libxl__carefd* instead. (Your patch is not unacceptable due to you
>> not making this change, on the basis that we should accept
>> improvements even if they don't leave the code perfect.)
>
> And indeed I'd like to leave that conversion to you or someone
> else more familiar with the libxl concepts.
>
>>> --- a/tools/libxl/libxl_utils.c
>>> +++ b/tools/libxl/libxl_utils.c
>>> @@ -1047,11 +1047,17 @@ int libxl__random_bytes(libxl__gc *gc, u
>> ...
>>> - fd = open(dev, O_RDONLY | O_CLOEXEC);
>>> + fd = open(dev, O_RDONLY);
>>
>> Firstly, I don't understand why we care about cloexec on this fd, but
>> it's harmless to do so.
>
> And of course I'd be perfectly fine with a one liner just dropping it
> (all I really care about is that the file builds correctly in all cases).
> The question of why cloexec is needed/wanted here I'll pass on to
> author and committer, but I'd guess this is just to avoid
> proliferation of file handles into clones.
Surely it should be standard practice for a library to always set
CLOEXEC on any files it opens, to minimize the side effects the library
call has?
And if CLOEXEC is required then setting it at open time is the only safe
way.
David
next prev parent reply other threads:[~2014-07-28 14:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-25 15:02 [PATCH] libxl: use libxl_fd_set_{cloexec, nonblock} helpers Jan Beulich
2014-07-25 17:07 ` Ian Jackson
2014-07-28 6:32 ` Jan Beulich
2014-07-28 14:51 ` David Vrabel [this message]
2014-07-29 9:15 ` Ian Campbell
2014-08-01 13:43 ` Don Slutz
2014-07-28 7:30 ` [PATCH v2] " Jan Beulich
2014-07-29 14:29 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53D66362.8000901@citrix.com \
--to=david.vrabel@citrix.com \
--cc=Ian.Campbell@eu.citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.