unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: Felipe Contreras <felipe.contreras@gmail.com>
Cc: Ali Polatel <alip@exherbo.org>, notmuch@notmuchmail.org
Subject: Re: [PATCH] ruby: make sure the database is closed
Date: Mon, 23 Apr 2012 21:15:28 -0400	[thread overview]
Message-ID: <20120424011528.GA12459@mit.edu> (raw)
In-Reply-To: <CAMP44s2qmPWZk=1N8L1aOnDb7b81kthNB-Gj798wdwBdtbBjFQ@mail.gmail.com>

Quoth Felipe Contreras on Apr 24 at  3:45 am:
> On Tue, Apr 24, 2012 at 2:46 AM, Ali Polatel <alip@exherbo.org> wrote:
> > 2012/4/24 Felipe Contreras <felipe.contreras@gmail.com>:
> 
> >> Personally I don't see why an object, like say a query would remain
> >> working correctly after the database is gone, either by calling
> >> .close() directly, or just loosing the pointer to the original object.
> >> I don't think users would expect that, or, even if they somehow found
> >> it useful, that most likely would be very seldom, and hardly worth
> >> worrying about it.
> >
> > Working correctly is not expected but wouldn't it be more appropriate
> > to throw an exception rather than dumping core or printing on standard error?
> 
> Sure, if that was possible.
> 
> > I wonder whether we can make both work somehow.
> > Maybe by using talloc explicitly and keeping reference pointers?
> > I don't know whether it's worth bothering.
> 
> Maybe, I don't see how, that's just not how C works. Maybe talloc does
> have some way to figure out if a pointer has been freed, but I doubt
> that, and I can't find it by grepping through the API.
> 
> Another option would be hook into talloc's destructor so we know when
> an object is freed and taint it, but then we would be overriding
> notmuch's destructor, and there's no way around that (unless we tap
> into talloc's internal structures). A way to workaround that would be
> to modify notmuch's API so that we can specify a destructor for
> notmuch objects, but that would be tedious, and I doubt a lof people
> beside us would benefit from that.

I believe (though I might be wrong) that bindings could simply
maintain their own talloc references to C objects returned by
libnotmuch to prevent them from being freed until the wrapper object
is garbage collected.  This would require modifying all of the
library's _destroy functions to use talloc_find_parent_bytype and
talloc_unlink instead of simply calling talloc_free, but I don't think
this change would be particularly invasive and it certainly wouldn't
affect the library interface.

  reply	other threads:[~2012-04-24  1:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-23 12:43 [PATCH] ruby: make sure the database is closed Felipe Contreras
2012-04-23 14:04 ` Ali Polatel
2012-04-23 15:07   ` Felipe Contreras
2012-04-23 20:43     ` Ali Polatel
2012-04-23 22:45       ` Felipe Contreras
2012-04-23 23:46         ` Ali Polatel
2012-04-24  0:45           ` Felipe Contreras
2012-04-24  1:15             ` Austin Clements [this message]
2012-04-24 10:30               ` Felipe Contreras
2012-04-25 20:22                 ` Ali Polatel
  -- strict thread matches above, loose matches on Subject: below --
2012-04-23 12:48 Felipe Contreras

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

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120424011528.GA12459@mit.edu \
    --to=amdragon@mit.edu \
    --cc=alip@exherbo.org \
    --cc=felipe.contreras@gmail.com \
    --cc=notmuch@notmuchmail.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.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).