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 BCA20431FAF for ; Mon, 23 Apr 2012 18:15:33 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[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 XOJhte3pNoke for ; Mon, 23 Apr 2012 18:15:33 -0700 (PDT) Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU [18.9.25.15]) by olra.theworths.org (Postfix) with ESMTP id 051C6431FAE for ; Mon, 23 Apr 2012 18:15:32 -0700 (PDT) X-AuditID: 1209190f-b7f8a6d000000914-6a-4f95feb45ea6 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP id 5A.63.02324.4BEF59F4; Mon, 23 Apr 2012 21:15:32 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q3O1FUfv000505; Mon, 23 Apr 2012 21:15:31 -0400 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q3O1FTmT014132 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Mon, 23 Apr 2012 21:15:30 -0400 (EDT) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1SMULo-00046f-OU; Mon, 23 Apr 2012 21:15:28 -0400 Date: Mon, 23 Apr 2012 21:15:28 -0400 From: Austin Clements To: Felipe Contreras Subject: Re: [PATCH] ruby: make sure the database is closed Message-ID: <20120424011528.GA12459@mit.edu> References: <1335185032-13075-1-git-send-email-felipe.contreras@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFKsWRmVeSWpSXmKPExsUixG6nrrvl31R/g97zHBarvt1ltDj4OM/i +s2ZzA7MHhufNrF77Jx1l93j2apbzAHMUVw2Kak5mWWpRfp2CVwZ0w+1sxVcEaiYvXoJawPj Wt4uRk4OCQETiRXrTjNB2GISF+6tZ+ti5OIQEtjHKPGveRELhLOBUWLPytlQmZNMEhv3/ITK LGGU2Hx9PitIP4uAqsTWY72MIDabgIbEtv3LwWwRAUOJve1TWUBsZgFriXuHtoLZwkD2mSN7 wGxeAR2JqVdms0IM/cIs8XvzKmaIhKDEyZlPoJq1JG78ewl0LAeQLS2x/B8HSJhTIFCi8cgi sB9EBVQkppzcxjaBUWgWku5ZSLpnIXQvYGRexSibklulm5uYmVOcmqxbnJyYl5dapGuil5tZ opeaUrqJERTsnJL8Oxi/HVQ6xCjAwajEw5uVPtVfiDWxrLgy9xCjJAeTkijvyt9AIb6k/JTK jMTijPii0pzU4kOMEhzMSiK8iROAcrwpiZVVqUX5MClpDhYlcV41rXd+QgLpiSWp2ampBalF MFkZDg4lCV4eYFQLCRalpqdWpGXmlCCkmTg4QYbzAA1f8hdkeHFBYm5xZjpE/hSjLse1L0ev MAqx5OXnpUqJ864GKRIAKcoozYObA0tSrxjFgd4S5t0NUsUDTHBwk14BLWECWpIQMwlkSUki QkqqgZG3xWHqvjdGjzalfdm24raRWPz5uPA2u9WNaxvLpxzMmHTUevnDkoSE2tshXW+Svj66 67d52zuVVMOY2fcsFm3b9I/txwYpuVdbtx+cvCEn+DGPt+dGEzPGfRyb9LmOcZvwbZY9v3Pn NW7P17EPq+KV314sOp16zPIgjyrXpGezz0g056VG1SgosRRnJBpqMRcVJwIA2G+3ry0DAAA= 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 01:15:33 -0000 Quoth Felipe Contreras on Apr 24 at 3: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. 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.