--- /dev/null
+Return-Path: <felipe.contreras@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id DA4B1431FAF\r
+ for <notmuch@notmuchmail.org>; Mon, 23 Apr 2012 15:45:27 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 9EJoSm1zJ7WM for <notmuch@notmuchmail.org>;\r
+ Mon, 23 Apr 2012 15:45:26 -0700 (PDT)\r
+Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com\r
+ [74.125.83.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 5B548431FAE for <notmuch@notmuchmail.org>; Mon, 23 Apr 2012 15:45:26 -0700\r
+ (PDT)\r
+Received: by eekb47 with SMTP id b47so17209eek.26\r
+ for <notmuch@notmuchmail.org>; Mon, 23 Apr 2012 15:45:23 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=mime-version:in-reply-to:references:date:message-id:subject:from:to\r
+ :cc:content-type:content-transfer-encoding;\r
+ bh=Mw+5107Em+k4IeaifxjICdR6z2LCM/P0wyPcYzcBQ54=;\r
+ b=XojguKhbBk5PVo6u7YZJFqJf+baf6MzlMM+bgsgV5+43sQ0jak3iWYfDTX/XpehQBw\r
+ YK8KQ8yooKWLn8eUD6n9Jj9ymjL6Kr0uE7cCtAoTP1AwQH8swff/OVCV4VXGeLU0coTI\r
+ yiEyO7p7k3HDU7zqtphQB5+Z9EGM1Oo6TMlg7ya1NSuI91HFD1mKvxQpZidInv7uue/D\r
+ ZS/Jfstfq4mc5A47mSiP8AZN5fTPfB94Kr+eRnlliQ77LhR0Qb+Dgb5mSuSOOa/1mgMt\r
+ +HVeuOooMW9800ixIJQPXrkbD1sH2eNyoICJ+B1fncZsvFMFtIJKSfuNjNV3jaMdzpjW\r
+ MFfQ==\r
+MIME-Version: 1.0\r
+Received: by 10.213.9.209 with SMTP id m17mr1424450ebm.19.1335221123501; Mon,\r
+ 23 Apr 2012 15:45:23 -0700 (PDT)\r
+Received: by 10.213.103.18 with HTTP; Mon, 23 Apr 2012 15:45:23 -0700 (PDT)\r
+In-Reply-To:\r
+ <CADv3eywb0tguYowTAK5Ag9YZ48zFZA0QJVNEj_cZcCpr-76Bbg@mail.gmail.com>\r
+References: <1335185032-13075-1-git-send-email-felipe.contreras@gmail.com>\r
+ <CADv3eywAvyMuh3vWLwyuf0Ui_kskwp9875pGxCR1GTm7deN9Pg@mail.gmail.com>\r
+ <CAMP44s3SyU4WVV0_McHWseNL=jmMnAXO2EdZK4Xk-wrCHPVD8A@mail.gmail.com>\r
+ <CADv3eywb0tguYowTAK5Ag9YZ48zFZA0QJVNEj_cZcCpr-76Bbg@mail.gmail.com>\r
+Date: Tue, 24 Apr 2012 01:45:23 +0300\r
+Message-ID:\r
+ <CAMP44s0=m+PmVBdVytHaYujpaZu=2WH+1F_VoMzpfXH+SS_ZmQ@mail.gmail.com>\r
+Subject: Re: [PATCH] ruby: make sure the database is closed\r
+From: Felipe Contreras <felipe.contreras@gmail.com>\r
+To: Ali Polatel <alip@exherbo.org>\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: quoted-printable\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 23 Apr 2012 22:45:28 -0000\r
+\r
+On Mon, Apr 23, 2012 at 11:43 PM, Ali Polatel <alip@exherbo.org> wrote:\r
+> 2012/4/23 Felipe Contreras <felipe.contreras@gmail.com>:\r
+>> On Mon, Apr 23, 2012 at 5:04 PM, Ali Polatel <alip@exherbo.org> wrote:\r
+>>\r
+>>> I'd rather not do this.\r
+>>> Please read: http://comments.gmane.org/gmane.comp.lang.ruby.general/320=\r
+324\r
+>>\r
+>> OK, I've read this.. So?\r
+>\r
+> You are one step close to what I thought you had thought.\r
+\r
+I don't parse that. I meant that _now_ I've read it.\r
+\r
+>> The order in which Ruby's garbage-collector frees the database and\r
+>> other objects is irrelevant, because with this patch we are not\r
+>> manually freeing other objects, only the database.\r
+>\r
+> What I wanted was to make all objects "depending" on the database to be u=\r
+nusable\r
+> once the database object is freed. Seeing that's not practically easy\r
+> I decided to leave\r
+> it to the user.\r
+\r
+Well, sure, but if the user has problems, the user can keep the\r
+database object around.\r
+\r
+Personally I don't see why an object, like say a query would remain\r
+working correctly after the database is gone, either by calling\r
+.close() directly, or just loosing the pointer to the original object.\r
+I don't think users would expect that, or, even if they somehow found\r
+it useful, that most likely would be very seldom, and hardly worth\r
+worrying about it.\r
+\r
+>> Sure, it's _better_ if the user calls close(), even better if it's\r
+>> inside an 'ensure', and even better if blocks are used (which I am\r
+>> using in most cases), but that's not *required*.\r
+>\r
+> If you have such a use case, I'm fine with that patch.\r
+> I might push it in the next few days or get someone else to push it.\r
+\r
+I did at some point, not sure if I do now. But that's beside the\r
+point, the point is that it really does happen.\r
+\r
+>> The user might just do:\r
+>>\r
+>> def foo\r
+>> =C2=A0db =3D Notmuch::Database.new($db_name, :mode =3D> Notmuch::MODE_RE=\r
+AD_WRITE)\r
+>> end\r
+>>\r
+>> That's perfectly fine in Ruby (although not ideal), since 'db' will\r
+>> get garbage-collected. But nobody will be able to use the database\r
+>> again until that process is killed.\r
+>>\r
+>> You think that's correct?\r
+>\r
+> Yes that is correct. I have not thought about this.\r
+> I'd say it's a partial misunderstanding on my part due to lack of\r
+> (and/or too much) vodka.\r
+\r
+Well, there's only two options.\r
+\r
+a) This works:\r
+\r
+ def foo\r
+ db =3D Notmuch::Database.new($db_name, :mode =3D> Notmuch::MODE_READ_WR=\r
+ITE)\r
+ end\r
+\r
+(as in; the database gets closed eventually)\r
+\r
+b) This works:\r
+\r
+ def start_query(search)\r
+ db =3D Notmuch::Database.new($db_name)\r
+ return db.query(search)\r
+ end\r
+\r
+(as in; the query returned would keep working properly)\r
+\r
+I personally don't see why anybody would want b), and if they have\r
+problems with code like that, I think it's obvious to see why.\r
+\r
+I think we should go for a) and thus apply the patch.\r
+\r
+Cheers.\r
+\r
+--=20\r
+Felipe Contreras\r