--- /dev/null
+Return-Path: <amdragon@mit.edu>\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 BCA20431FAF\r
+ for <notmuch@notmuchmail.org>; Mon, 23 Apr 2012 18:15:33 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[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 XOJhte3pNoke for <notmuch@notmuchmail.org>;\r
+ Mon, 23 Apr 2012 18:15:33 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU\r
+ [18.9.25.15])\r
+ by olra.theworths.org (Postfix) with ESMTP id 051C6431FAE\r
+ for <notmuch@notmuchmail.org>; Mon, 23 Apr 2012 18:15:32 -0700 (PDT)\r
+X-AuditID: 1209190f-b7f8a6d000000914-6a-4f95feb45ea6\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 5A.63.02324.4BEF59F4; Mon, 23 Apr 2012 21:15:32 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q3O1FUfv000505; \r
+ Mon, 23 Apr 2012 21:15:31 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+ (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q3O1FTmT014132\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Mon, 23 Apr 2012 21:15:30 -0400 (EDT)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1SMULo-00046f-OU; Mon, 23 Apr 2012 21:15:28 -0400\r
+Date: Mon, 23 Apr 2012 21:15:28 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Felipe Contreras <felipe.contreras@gmail.com>\r
+Subject: Re: [PATCH] ruby: make sure the database is closed\r
+Message-ID: <20120424011528.GA12459@mit.edu>\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
+ <CAMP44s0=m+PmVBdVytHaYujpaZu=2WH+1F_VoMzpfXH+SS_ZmQ@mail.gmail.com>\r
+ <CADv3eyxcu=2ZJ7GH3WULKMqe6FdmzhPtU6K9MLcCQ4m0cWmM7A@mail.gmail.com>\r
+ <CAMP44s2qmPWZk=1N8L1aOnDb7b81kthNB-Gj798wdwBdtbBjFQ@mail.gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To:\r
+ <CAMP44s2qmPWZk=1N8L1aOnDb7b81kthNB-Gj798wdwBdtbBjFQ@mail.gmail.com>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFprFKsWRmVeSWpSXmKPExsUixG6nrrvl31R/g97zHBarvt1ltDj4OM/i\r
+ +s2ZzA7MHhufNrF77Jx1l93j2apbzAHMUVw2Kak5mWWpRfp2CVwZ0w+1sxVcEaiYvXoJawPj\r
+ Wt4uRk4OCQETiRXrTjNB2GISF+6tZ+ti5OIQEtjHKPGveRELhLOBUWLPytlQmZNMEhv3/ITK\r
+ LGGU2Hx9PitIP4uAqsTWY72MIDabgIbEtv3LwWwRAUOJve1TWUBsZgFriXuHtoLZwkD2mSN7\r
+ wGxeAR2JqVdms0IM/cIs8XvzKmaIhKDEyZlPoJq1JG78ewl0LAeQLS2x/B8HSJhTIFCi8cgi\r
+ sB9EBVQkppzcxjaBUWgWku5ZSLpnIXQvYGRexSibklulm5uYmVOcmqxbnJyYl5dapGuil5tZ\r
+ opeaUrqJERTsnJL8Oxi/HVQ6xCjAwajEw5uVPtVfiDWxrLgy9xCjJAeTkijvyt9AIb6k/JTK\r
+ jMTijPii0pzU4kOMEhzMSiK8iROAcrwpiZVVqUX5MClpDhYlcV41rXd+QgLpiSWp2ampBalF\r
+ MFkZDg4lCV4eYFQLCRalpqdWpGXmlCCkmTg4QYbzAA1f8hdkeHFBYm5xZjpE/hSjLse1L0ev\r
+ MAqx5OXnpUqJ864GKRIAKcoozYObA0tSrxjFgd4S5t0NUsUDTHBwk14BLWECWpIQMwlkSUki\r
+ QkqqgZG3xWHqvjdGjzalfdm24raRWPz5uPA2u9WNaxvLpxzMmHTUevnDkoSE2tshXW+Svj66\r
+ 67d52zuVVMOY2fcsFm3b9I/txwYpuVdbtx+cvCEn+DGPt+dGEzPGfRyb9LmOcZvwbZY9v3Pn\r
+ NW7P17EPq+KV314sOp16zPIgjyrXpGezz0g056VG1SgosRRnJBpqMRcVJwIA2G+3ry0DAAA=\r
+Cc: Ali Polatel <alip@exherbo.org>, 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: Tue, 24 Apr 2012 01:15:33 -0000\r
+\r
+Quoth Felipe Contreras on Apr 24 at 3:45 am:\r
+> On Tue, Apr 24, 2012 at 2:46 AM, Ali Polatel <alip@exherbo.org> wrote:\r
+> > 2012/4/24 Felipe Contreras <felipe.contreras@gmail.com>:\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
+> > Working correctly is not expected but wouldn't it be more appropriate\r
+> > to throw an exception rather than dumping core or printing on standard error?\r
+> \r
+> Sure, if that was possible.\r
+> \r
+> > I wonder whether we can make both work somehow.\r
+> > Maybe by using talloc explicitly and keeping reference pointers?\r
+> > I don't know whether it's worth bothering.\r
+> \r
+> Maybe, I don't see how, that's just not how C works. Maybe talloc does\r
+> have some way to figure out if a pointer has been freed, but I doubt\r
+> that, and I can't find it by grepping through the API.\r
+> \r
+> Another option would be hook into talloc's destructor so we know when\r
+> an object is freed and taint it, but then we would be overriding\r
+> notmuch's destructor, and there's no way around that (unless we tap\r
+> into talloc's internal structures). A way to workaround that would be\r
+> to modify notmuch's API so that we can specify a destructor for\r
+> notmuch objects, but that would be tedious, and I doubt a lof people\r
+> beside us would benefit from that.\r
+\r
+I believe (though I might be wrong) that bindings could simply\r
+maintain their own talloc references to C objects returned by\r
+libnotmuch to prevent them from being freed until the wrapper object\r
+is garbage collected. This would require modifying all of the\r
+library's _destroy functions to use talloc_find_parent_bytype and\r
+talloc_unlink instead of simply calling talloc_free, but I don't think\r
+this change would be particularly invasive and it certainly wouldn't\r
+affect the library interface.\r