[PATCH 6/8] CLI: refactor dumping of tags.
[notmuch-archives.git] / cc / 0bf04abb795887d8cffcf4de1a8821f8f1cd3c
1 Return-Path: <notmuch@kismala.com>\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 arlo.cworth.org (Postfix) with ESMTP id D96FD6DE01F7\r
6  for <notmuch@notmuchmail.org>; Tue,  3 May 2016 12:13:06 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.103\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.103 tagged_above=-999 required=5 tests=[AWL=0.103]\r
12  autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id uAvVGx1RDjgi for <notmuch@notmuchmail.org>;\r
16  Tue,  3 May 2016 12:12:58 -0700 (PDT)\r
17 Received: from imarko.xen.prgmr.com (imarko.xen.prgmr.com [71.19.158.228])\r
18  by arlo.cworth.org (Postfix) with ESMTP id BEA246DE00DF\r
19  for <notmuch@notmuchmail.org>; Tue,  3 May 2016 12:12:58 -0700 (PDT)\r
20 Received: from localhost ([127.0.0.1] helo=zsu.kismala.com)\r
21  by imarko.xen.prgmr.com with esmtp (Exim 4.85)\r
22  (envelope-from <notmuch@kismala.com>)\r
23  id 1axfkf-0002jF-Al; Tue, 03 May 2016 12:12:57 -0700\r
24 From: Istvan Marko <notmuch@kismala.com>\r
25 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
26 Subject: [PATCH v2] Use the Xapian::DB_RETRY_LOCK flag when available\r
27 In-Reply-To: <87k2jbgl2b.fsf@nikula.org>\r
28 References: <m38tzr2n6v.fsf@zsu.kismala.com> <87k2jbgl2b.fsf@nikula.org>\r
29 User-Agent: Notmuch/0.21+69~gd27d908 (http://notmuchmail.org) Emacs/25.0.92.2\r
30  (x86_64-unknown-linux-gnu)\r
31 Date: Tue, 03 May 2016 12:12:57 -0700\r
32 Message-ID: <m3wpnb0xc6.fsf@zsu.kismala.com>\r
33 MIME-Version: 1.0\r
34 Content-Type: text/plain\r
35 X-BeenThere: notmuch@notmuchmail.org\r
36 X-Mailman-Version: 2.1.20\r
37 Precedence: list\r
38 List-Id: "Use and development of the notmuch mail system."\r
39  <notmuch.notmuchmail.org>\r
40 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
41  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
43 List-Post: <mailto:notmuch@notmuchmail.org>\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
45 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
46  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
47 X-List-Received-Date: Tue, 03 May 2016 19:13:07 -0000\r
48 \r
49 Xapian 1.3 has introduced the DB_RETRY_LOCK flag (Xapian bug\r
50 275). Detect it in configure and use it if available. With this flag\r
51 commands that need the write lock will wait for their turn instead of\r
52 aborting when it's not immediately available.\r
53 ---\r
54 \r
55 Updated based on Jani's feedback.\r
56 \r
57 Regarding tests, I couldn't think of a meaningful test for this. We get\r
58 different behaviors depending on the Xapian version and if we try do\r
59 some kind of a concurrent locking test we'd really be just testing\r
60 Xapian's locking code rather than notmuch.\r
61 \r
62  configure       | 20 ++++++++++++++++++++\r
63  lib/database.cc |  8 +++++++-\r
64  2 files changed, 27 insertions(+), 1 deletion(-)\r
65 \r
66 diff --git a/configure b/configure\r
67 index 6231d2b..8ef96b4 100755\r
68 --- a/configure\r
69 +++ b/configure\r
70 @@ -371,6 +371,21 @@ if [ ${have_xapian} = "1" ]; then\r
71      esac\r
72  fi\r
73  \r
74 +# DB_RETRY_LOCK is only supported on Xapian > 1.3.2\r
75 +have_xapian_db_retry_lock=0\r
76 +if [ ${have_xapian} = "1" ]; then\r
77 +    printf "Checking for Xapian lock retry support... "\r
78 +    case "${xapian_version}" in\r
79 +       0.*|1.[012].*|1.3.[0-2])\r
80 +           printf "No (only available with Xapian > 1.3.2).\n" ;;\r
81 +       [1-9]*.[0-9]*.[0-9]*)\r
82 +           have_xapian_db_retry_lock=1\r
83 +           printf "Yes.\n" ;;\r
84 +       *)\r
85 +           printf "Unknown version.\n" ;;\r
86 +    esac\r
87 +fi\r
88 +\r
89  default_xapian_backend=""\r
90  if [ ${have_xapian} = "1" ]; then\r
91      printf "Testing default Xapian backend... "\r
92 @@ -998,6 +1013,9 @@ HAVE_D_TYPE = ${have_d_type}\r
93  # Whether the Xapian version in use supports compaction\r
94  HAVE_XAPIAN_COMPACT = ${have_xapian_compact}\r
95  \r
96 +# Whether the Xapian version in use supports DB_RETRY_LOCK\r
97 +HAVE_XAPIAN_DB_RETRY_LOCK = ${have_xapian_db_retry_lock}\r
98 +\r
99  # Whether the getpwuid_r function is standards-compliant\r
100  # (if not, then notmuch will #define _POSIX_PTHREAD_SEMANTICS\r
101  # to enable the standards-compliant version -- needed for Solaris)\r
102 @@ -1072,6 +1090,7 @@ CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)      \\\r
103                    -DSTD_GETPWUID=\$(STD_GETPWUID)                       \\\r
104                    -DSTD_ASCTIME=\$(STD_ASCTIME)                         \\\r
105                    -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)         \\\r
106 +                  -DHAVE_XAPIAN_DB_RETRY_LOCK=\$(HAVE_XAPIAN_DB_RETRY_LOCK) \\\r
107                    -DUTIL_BYTE_ORDER=\$(UTIL_BYTE_ORDER)\r
108  \r
109  CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\\r
110 @@ -1086,6 +1105,7 @@ CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\\r
111                      -DSTD_GETPWUID=\$(STD_GETPWUID)                     \\\r
112                      -DSTD_ASCTIME=\$(STD_ASCTIME)                       \\\r
113                      -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)       \\\r
114 +                     -DHAVE_XAPIAN_DB_RETRY_LOCK=\$(HAVE_XAPIAN_DB_RETRY_LOCK) \\\r
115                      -DUTIL_BYTE_ORDER=\$(UTIL_BYTE_ORDER)\r
116  \r
117  CONFIGURE_LDFLAGS =  \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(ZLIB_LDFLAGS) \$(XAPIAN_LDFLAGS)\r
118 diff --git a/lib/database.cc b/lib/database.cc\r
119 index c8c5e26..c0fcb29 100644\r
120 --- a/lib/database.cc\r
121 +++ b/lib/database.cc\r
122 @@ -48,6 +48,12 @@ typedef struct {\r
123  #define STRINGIFY(s) _SUB_STRINGIFY(s)\r
124  #define _SUB_STRINGIFY(s) #s\r
125  \r
126 +#if HAVE_XAPIAN_DB_RETRY_LOCK\r
127 +#define DB_ACTION (Xapian::DB_CREATE_OR_OPEN | Xapian::DB_RETRY_LOCK)\r
128 +#else\r
129 +#define DB_ACTION Xapian::DB_CREATE_OR_OPEN\r
130 +#endif\r
131 +\r
132  /* Here's the current schema for our database (for NOTMUCH_DATABASE_VERSION):\r
133   *\r
134   * We currently have three different types of documents (mail, ghost,\r
135 @@ -930,7 +936,7 @@ notmuch_database_open_verbose (const char *path,\r
136  \r
137         if (mode == NOTMUCH_DATABASE_MODE_READ_WRITE) {\r
138             notmuch->xapian_db = new Xapian::WritableDatabase (xapian_path,\r
139 -                                                              Xapian::DB_CREATE_OR_OPEN);\r
140 +                                                              DB_ACTION);\r
141         } else {\r
142             notmuch->xapian_db = new Xapian::Database (xapian_path);\r
143         }\r
144 -- \r
145 2.4.10\r
146 \r
147 \r
148 -- \r
149         Istvan\r