Re: [PATCH] lib: provide _notmuch_database_log_append
[notmuch-archives.git] / 37 / 4a33ffe99f92a52d2083f5f85c88458f8873ba
1 Return-Path: <teythoon@jade-hamburg.de>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 9A3B4431FB6\r
6         for <notmuch@notmuchmail.org>; Fri,  2 Mar 2012 06:58:55 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id rOSot76qKhGj for <notmuch@notmuchmail.org>;\r
16         Fri,  2 Mar 2012 06:58:54 -0800 (PST)\r
17 Received: from mail.cryptobitch.de (cryptobitch.de [88.198.7.68])\r
18         (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id B5C8E431FAE\r
21         for <notmuch@notmuchmail.org>; Fri,  2 Mar 2012 06:58:54 -0800 (PST)\r
22 Received: from mail.jade-hamburg.de (unknown [85.183.11.228])\r
23         (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
24         (No client certificate requested)\r
25         by mail.cryptobitch.de (Postfix) with ESMTPSA id EF2E05756A2\r
26         for <notmuch@notmuchmail.org>; Fri,  2 Mar 2012 15:58:52 +0100 (CET)\r
27 Received: by mail.jade-hamburg.de (Postfix, from userid 401)\r
28         id 626A3DF2A6; Fri,  2 Mar 2012 15:58:52 +0100 (CET)\r
29 Received: from thinkbox.jade-hamburg.de (unknown [10.1.1.153])\r
30         (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
31         (No client certificate requested) (Authenticated sender: teythoon)\r
32         by mail.jade-hamburg.de (Postfix) with ESMTPSA id 280BCDF2A2;\r
33         Fri,  2 Mar 2012 15:58:50 +0100 (CET)\r
34 Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.77)\r
35         (envelope-from <teythoon@thinkbox.jade-hamburg.de>)\r
36         id 1S3TwX-0006uY-Sk; Fri, 02 Mar 2012 15:58:49 +0100\r
37 From: Justus Winter <4winter@informatik.uni-hamburg.de>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH] Actually close the xapian database in notmuch_database_close\r
40 Date: Fri,  2 Mar 2012 15:58:39 +0100\r
41 Message-Id:\r
42  <1330700319-26531-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
43 X-Mailer: git-send-email 1.7.9.1\r
44 In-Reply-To: <20120301181141.GA4797@mit.edu>\r
45 References: <20120301181141.GA4797@mit.edu>\r
46 X-BeenThere: notmuch@notmuchmail.org\r
47 X-Mailman-Version: 2.1.13\r
48 Precedence: list\r
49 List-Id: "Use and development of the notmuch mail system."\r
50         <notmuch.notmuchmail.org>\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
54 List-Post: <mailto:notmuch@notmuchmail.org>\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
58 X-List-Received-Date: Fri, 02 Mar 2012 14:58:56 -0000\r
59 \r
60 Formerly the xapian database object was deleted and closed in its\r
61 destructor once the object was garbage collected. Explicitly call\r
62 close() so that the database and the associated lock is released\r
63 immediately.\r
64 \r
65 The comment is a courtesy of Austin Clements.\r
66 \r
67 Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>\r
68 ---\r
69  lib/database.cc |   11 +++++++++++\r
70  1 files changed, 11 insertions(+), 0 deletions(-)\r
71 \r
72 diff --git a/lib/database.cc b/lib/database.cc\r
73 index 5efa85e..8f8df1a 100644\r
74 --- a/lib/database.cc\r
75 +++ b/lib/database.cc\r
76 @@ -726,6 +726,17 @@ notmuch_database_close (notmuch_database_t *notmuch)\r
77         }\r
78      }\r
79  \r
80 +    /* Many Xapian objects (and thus notmuch objects) hold references to\r
81 +     * the database, so merely deleting the database may not suffice to\r
82 +     * close it.  Thus, we explicitly close it here. */\r
83 +    if (notmuch->xapian_db != NULL) {\r
84 +       try {\r
85 +           notmuch->xapian_db->close();\r
86 +       } catch (const Xapian::Error &error) {\r
87 +           /* do nothing */\r
88 +       }\r
89 +    }\r
90 +\r
91      delete notmuch->term_gen;\r
92      delete notmuch->query_parser;\r
93      delete notmuch->xapian_db;\r
94 -- \r
95 1.7.9.1\r
96 \r