Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 5BB80431FAF for ; Tue, 24 Apr 2012 03:30:13 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QL+9fZrMqOaw for ; Tue, 24 Apr 2012 03:30:12 -0700 (PDT) Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com [74.125.83.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 7CC08431FAE for ; Tue, 24 Apr 2012 03:30:12 -0700 (PDT) Received: by eekb47 with SMTP id b47so223628eek.26 for ; Tue, 24 Apr 2012 03:30:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=Vig6HAsMBRXTl+T7ZiXCJXNXNwVSxOGSFe8qW7zXh+g=; b=JhNO6ytWZoI9xgzeEkQkM/TVSvdSwdbxsOOloAJPbGsQWUe63SrssYmZn7u1SQHTTV MePF6yBFE7KmHxncGe2cu5uyO7+CYqKgPN+ju4r9IjH6yoARe81TsAR/o9/ETOAPCbWJ wL1HO9YNcJsI8vOV4OejZeB/zLS072G2/CFtyWlDzr9yzNBnnWY0JsQrFnYRpNW1dHk5 fP/lbrl0J+WJPrnXFOE1wj948WwPt8o+plHhoGNqTSIg8uFGRi+a6IAglO+EitV6gWG7 JohA98SYH5ZJ8IU1al/rp0uupiBULQS/Wmh5St5DbGLqxRwHddqo0zZfsgbGD9RTuWz9 962g== MIME-Version: 1.0 Received: by 10.14.50.74 with SMTP id y50mr1344928eeb.107.1335263411113; Tue, 24 Apr 2012 03:30:11 -0700 (PDT) Received: by 10.213.103.18 with HTTP; Tue, 24 Apr 2012 03:30:11 -0700 (PDT) In-Reply-To: <20120424011528.GA12459@mit.edu> References: <1335185032-13075-1-git-send-email-felipe.contreras@gmail.com> <20120424011528.GA12459@mit.edu> Date: Tue, 24 Apr 2012 13:30:11 +0300 Message-ID: Subject: Re: [PATCH] ruby: make sure the database is closed From: Felipe Contreras To: Austin Clements Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: Ali Polatel , notmuch@notmuchmail.org X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2012 10:30:13 -0000 On Tue, Apr 24, 2012 at 4:15 AM, Austin Clements wrote: > Quoth Felipe Contreras on Apr 24 at =C2=A03:45 am: >> On Tue, Apr 24, 2012 at 2:46 AM, Ali Polatel wrote: >> > 2012/4/24 Felipe Contreras : >> >> >> 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. =C2=A0This 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. That might work, but still, I don't see why this patch can't be applied. Cheers. --=20 Felipe Contreras