Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 5d / ec4dd831441f0a909a25d25618b569f345f93e
1 Return-Path: <amdragon@mit.edu>\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 333DE431FC0\r
6         for <notmuch@notmuchmail.org>; Mon, 22 Sep 2014 08:43:57 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] 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 lvH6LqRsPS2H for <notmuch@notmuchmail.org>;\r
16         Mon, 22 Sep 2014 08:43:51 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-7.mit.edu (dmz-mailsec-scanner-7.mit.edu\r
18         [18.7.68.36])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 92A42431FB6\r
22         for <notmuch@notmuchmail.org>; Mon, 22 Sep 2014 08:43:51 -0700 (PDT)\r
23 X-AuditID: 12074424-f79346d000004923-48-542043b60783\r
24 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
25         (using TLS with cipher AES256-SHA (256/256 bits))\r
26         (Client did not present a certificate)\r
27         by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
28         id B8.8B.18723.6B340245; Mon, 22 Sep 2014 11:43:50 -0400 (EDT)\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
30         by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id s8MFhndg028845; \r
31         Mon, 22 Sep 2014 11:43:49 -0400\r
32 Received: from drake.dyndns.org (navigator.sea-net.de [185.31.6.22])\r
33         (authenticated bits=0)\r
34         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
35         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s8MFhhkC032098\r
36         (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT);\r
37         Mon, 22 Sep 2014 11:43:48 -0400\r
38 Received: from amthrax by drake.dyndns.org with local (Exim 4.84)\r
39         (envelope-from <amdragon@mit.edu>)\r
40         id 1XW5mA-0005SM-3W; Mon, 22 Sep 2014 11:43:42 -0400\r
41 From: Austin Clements <amdragon@mit.edu>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH] lib: Simplify close and codify aborting atomic section\r
44 Date: Mon, 22 Sep 2014 11:43:35 -0400\r
45 Message-Id: <1411400615-20934-1-git-send-email-amdragon@mit.edu>\r
46 X-Mailer: git-send-email 2.1.0\r
47 X-Brightmail-Tracker:\r
48  H4sIAAAAAAAAA+NgFlrOIsWRmVeSWpSXmKPExsUixG6norvNWSHE4P43c4vrN2cyOzB6PFt1\r
49         izmAMYrLJiU1J7MstUjfLoEr4+P1RpaCWVIV2+/NY2xgnCzaxcjJISFgIrHgWgcLhC0mceHe\r
50         erYuRi4OIYHZTBK3JuxhgXA2Mkp8mdzGCOHsYpLYtqmPGcKZyyixYd1tdpB+NgENid+3FjOB\r
51         2CIC0hI7785m7WLk4GAWUJP406UCEhYWcJdYcngJ2DoWAVWJtYt3grXyCjhIrHjZyQZxhpzE\r
52         ht3/GScw8i5gZFjFKJuSW6Wbm5iZU5yarFucnJiXl1qka66Xm1mil5pSuokRHAYuKjsYmw8p\r
53         HWIU4GBU4uFd0CQfIsSaWFZcmXuIUZKDSUmU976pQogQX1J+SmVGYnFGfFFpTmrxIUYJDmYl\r
54         Ed4gaaAcb0piZVVqUT5MSpqDRUmcd9MPvhAhgfTEktTs1NSC1CKYrAwHh5IE73snoEbBotT0\r
55         1Iq0zJwShDQTByfIcB6g4YdBaniLCxJzizPTIfKnGHU51nV+62cSYsnLz0uVEuctASkSACnK\r
56         KM2DmwOL31eM4kBvCfM+BaniAcY+3KRXQEuYgJbcPy4PsqQkESEl1cB4uOWDV3DY/itROiaK\r
57         q9geTXM92BRv07vrrYoNy2tZ7wsRXJUrVonyrp/nurut73v8e29T5a9Pb9/JlAw9YbA0+oxE\r
58         a7vd6iXCnzRdJk9Rj5F0c/wxw8Xr5/0Ato2yuRzHGXdk5Pbuk0/hKXx2sXzhi72RlYbvk6fG\r
59         leb9rd06tf5sk4e78R8lluKMREMt5qLiRABec9EnugIAAA==\r
60 X-BeenThere: notmuch@notmuchmail.org\r
61 X-Mailman-Version: 2.1.13\r
62 Precedence: list\r
63 List-Id: "Use and development of the notmuch mail system."\r
64         <notmuch.notmuchmail.org>\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
68 List-Post: <mailto:notmuch@notmuchmail.org>\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
72 X-List-Received-Date: Mon, 22 Sep 2014 15:43:57 -0000\r
73 \r
74 In Xapian, closing a database implicitly aborts any outstanding\r
75 transaction and commits changes.  For historical reasons,\r
76 notmuch_database_close had grown to almost, but not quite duplicate\r
77 this behavior.  Before closing the database, it would explicitly (and\r
78 unnecessarily) commit it.  However, if there was an outstanding\r
79 transaction (ie atomic section), commit would throw a Xapian\r
80 exception, which notmuch_database_close would unnecessarily print to\r
81 stderr, even though notmuch_database_close would ultimately abort the\r
82 transaction anyway when it called close.\r
83 \r
84 This patch simplifies notmuch_database_close to just call\r
85 Database::close.  This works for both read-only and read/write\r
86 databases, takes care of committing changes, unifies the exception\r
87 handling path, and codifies aborting outstanding transactions.  This\r
88 is currently the only way to abort an atomic section (and may remain\r
89 so, since it would be difficult to roll back things we may have cached\r
90 from rolled-back modifications).\r
91 ---\r
92  lib/database.cc | 23 +++++++----------------\r
93  lib/notmuch.h   |  5 +++++\r
94  2 files changed, 12 insertions(+), 16 deletions(-)\r
95 \r
96 diff --git a/lib/database.cc b/lib/database.cc\r
97 index a3a7cd3..1f7ff2a 100644\r
98 --- a/lib/database.cc\r
99 +++ b/lib/database.cc\r
100 @@ -903,28 +903,19 @@ notmuch_database_close (notmuch_database_t *notmuch)\r
101  {\r
102      notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;\r
103  \r
104 -    try {\r
105 -       if (notmuch->xapian_db != NULL &&\r
106 -           notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE)\r
107 -           (static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db))->flush ();\r
108 -    } catch (const Xapian::Error &error) {\r
109 -       status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;\r
110 -       if (! notmuch->exception_reported) {\r
111 -           fprintf (stderr, "Error: A Xapian exception occurred flushing database: %s\n",\r
112 -                    error.get_msg().c_str());\r
113 -       }\r
114 -    }\r
115 -\r
116      /* Many Xapian objects (and thus notmuch objects) hold references to\r
117       * the database, so merely deleting the database may not suffice to\r
118 -     * close it.  Thus, we explicitly close it here. */\r
119 +     * close it.  Thus, we explicitly close it here.  This will\r
120 +     * implicitly abort any outstanding transaction and commit changes. */\r
121      if (notmuch->xapian_db != NULL) {\r
122         try {\r
123             notmuch->xapian_db->close();\r
124         } catch (const Xapian::Error &error) {\r
125 -           /* don't clobber previous error status */\r
126 -           if (status == NOTMUCH_STATUS_SUCCESS)\r
127 -               status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;\r
128 +           status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;\r
129 +           if (! notmuch->exception_reported) {\r
130 +               fprintf (stderr, "Error: A Xapian exception occurred closing database: %s\n",\r
131 +                        error.get_msg().c_str());\r
132 +           }\r
133         }\r
134      }\r
135  \r
136 diff --git a/lib/notmuch.h b/lib/notmuch.h\r
137 index fe2340b..5c40c67 100644\r
138 --- a/lib/notmuch.h\r
139 +++ b/lib/notmuch.h\r
140 @@ -292,6 +292,11 @@ notmuch_database_open (const char *path,\r
141   * notmuch_database_close can be called multiple times.  Later calls\r
142   * have no effect.\r
143   *\r
144 + * If the caller is currently in an atomic section (there was a\r
145 + * notmuch_database_begin_atomic without a matching\r
146 + * notmuch_database_end_atomic), this will abort the atomic section,\r
147 + * discarding any modifications made in the atomic section.\r
148 + *\r
149   * Return value:\r
150   *\r
151   * NOTMUCH_STATUS_SUCCESS: Successfully closed the database.\r
152 -- \r
153 2.1.0\r
154 \r