From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: "Frank Ch. Eigler" <fche@redhat.com>
Cc: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] debuginfod-support.c: Use long-lived debuginfod_client
Date: Thu, 6 May 2021 15:11:51 -0400 [thread overview]
Message-ID: <a34a32f1-86a0-9f54-5d5e-46f5d43883ee@polymtl.ca> (raw)
In-Reply-To: <20210506184707.GA29815@redhat.com>
On 2021-05-06 2:47 p.m., Frank Ch. Eigler wrote:> Hi -
>
>> I think it would still be a good idea to properly close the client
>> at exit. Not because the memory leak is a concern, but because we
>> shouldn't assume what closing a debuginfod client (current or
>> future) does or does not do, so we shouldn't assume that we can get
>> away without calling debuginfo_end.
>
> If it's not hard to do, sure .... but wouldn't that necessitate
> exposing the pointer from function static scope again?
I don't think so, just make the static variable a unique pointer (the
type that you are removing in this patch). The destructor of the
unique_ptr will be called at program exit, closing the client cleanly.
That variable can be declared inside debuginfod_init, like Tom
suggested. Something like:
static debuginfo_client *
debuginfod_init ()
{
static debuginfod_client_up global_client;
if (global_client == nullptr)
global_client.reset (debuginfod_begin ());
return global_client.get ();
}
In that case, the debuginfod_init function should probably be renamed to
something like get_debuginfod_client, something like that.
>> A debuginfod client could eventually maintain some temporary files
>> that need to be deleted when closing in order not to litter /tmp,
>> some cache files need to be flushed, etc.
>
> I suspect that if we were to do any of those things in the future,
> we'd keep things clean by techniques like holding onto fd's to
> unlinked files, so process exit is enough. (We could make a
> commitment in the docs.)
That sounds like a good idea, this way even if the user of the client
crashes, there won't be any leftovers. However, committing to that in
the documentation just sounds like an unnecessary way to paint yourself
in a corner.
Simon
next prev parent reply other threads:[~2021-05-06 19:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-30 23:57 Aaron Merey via Gdb-patches
2021-05-04 14:27 ` Tom Tromey
2021-05-06 0:55 ` Frank Ch. Eigler via Gdb-patches
2021-05-06 17:27 ` Aaron Merey via Gdb-patches
2021-05-06 17:39 ` Tom Tromey
2021-05-06 18:03 ` Simon Marchi via Gdb-patches
2021-05-06 18:47 ` Frank Ch. Eigler via Gdb-patches
2021-05-06 19:11 ` Simon Marchi via Gdb-patches [this message]
2021-05-06 20:35 ` Aaron Merey via Gdb-patches
2021-05-06 21:45 ` Simon Marchi via Gdb-patches
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=a34a32f1-86a0-9f54-5d5e-46f5d43883ee@polymtl.ca \
--to=gdb-patches@sourceware.org \
--cc=fche@redhat.com \
--cc=simon.marchi@polymtl.ca \
--cc=tom@tromey.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox