From: Felipe Contreras Date: Tue, 24 Apr 2012 00:45:46 +0000 (+0300) Subject: Re: [PATCH] ruby: make sure the database is closed X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=3d9f46b76b4a4d755673ad5e436a416aeca2cbe5;p=notmuch-archives.git Re: [PATCH] ruby: make sure the database is closed --- diff --git a/39/cd48f99e76425b10774126f59ebf0c22ec5b61 b/39/cd48f99e76425b10774126f59ebf0c22ec5b61 new file mode 100644 index 000000000..2d16c9948 --- /dev/null +++ b/39/cd48f99e76425b10774126f59ebf0c22ec5b61 @@ -0,0 +1,103 @@ +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 CD88E431FAF + for ; Mon, 23 Apr 2012 17:45:49 -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 cDZXVI7Z2G6o for ; + Mon, 23 Apr 2012 17:45:49 -0700 (PDT) +Received: from mail-ey0-f181.google.com (mail-ey0-f181.google.com + [209.85.215.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 1522C431FAE + for ; Mon, 23 Apr 2012 17:45:48 -0700 (PDT) +Received: by eaa1 with SMTP id 1so39195eaa.26 + for ; Mon, 23 Apr 2012 17:45:46 -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; + bh=9jB0H7t1Q145JF1nCAeKJ6200LjvFMz1QyMp7qdchs0=; + b=TIniuAnvs3WnfqLO0RWWoyJ1JNIsFymZCljSbrbCydsQMJ+cdoyQcM/kSjnnxPQS4R + xUKk1hlpQ7gnpzIRchORMAHF87N0QtpCepREkVI+fmSg3fkDBMfymXTyz7rXeyYdMkr9 + T4/La0DMiX3PJ7r79puSv9NQyQbXkPojywaF6Yz7CkaazwzpHhEVidZ/nX34tpfbuzhM + KZifffitQe2Ft+lUt+cNopBC7DbTGOFm52ScIOoQbU/Y7CAhgkzJlkpArYiDUehzBzC7 + Q8seqmSfvdTlSZAoKFiT7Xb1MK07/rOpmpdYeN0+s/ZGbDmW5nidV12PpqkQEnbUygsR + zoRA== +MIME-Version: 1.0 +Received: by 10.14.96.129 with SMTP id r1mr2915427eef.86.1335228346317; Mon, + 23 Apr 2012 17:45:46 -0700 (PDT) +Received: by 10.213.103.18 with HTTP; Mon, 23 Apr 2012 17:45:46 -0700 (PDT) +In-Reply-To: + +References: <1335185032-13075-1-git-send-email-felipe.contreras@gmail.com> + + + + + +Date: Tue, 24 Apr 2012 03:45:46 +0300 +Message-ID: + +Subject: Re: [PATCH] ruby: make sure the database is closed +From: Felipe Contreras +To: Ali Polatel +Content-Type: text/plain; charset=UTF-8 +Cc: 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 00:45:49 -0000 + +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. + +In the meantime, it doesn't hurt to apply this patch. + +-- +Felipe Contreras