database error
[notmuch-archives.git] / 34 / 855bb0fc739f3d447d21418446a38ef18b07d0
1 Return-Path: <pieter@praet.org>\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 F259A42119E\r
6         for <notmuch@notmuchmail.org>; Thu, 30 Jun 2011 09:08:45 -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: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 R0nER-1lWA9g for <notmuch@notmuchmail.org>;\r
16         Thu, 30 Jun 2011 09:08:45 -0700 (PDT)\r
17 Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com\r
18         [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 3A58B42119B\r
21         for <notmuch@notmuchmail.org>; Thu, 30 Jun 2011 09:08:45 -0700 (PDT)\r
22 Received: by mail-wy0-f181.google.com with SMTP id 22so1843157wyh.26\r
23         for <notmuch@notmuchmail.org>; Thu, 30 Jun 2011 09:08:45 -0700 (PDT)\r
24 Received: by 10.216.160.78 with SMTP id t56mr1020705wek.14.1309450124822;\r
25         Thu, 30 Jun 2011 09:08:44 -0700 (PDT)\r
26 Received: from localhost ([109.131.21.173])\r
27         by mx.google.com with ESMTPS id m46sm47142weq.15.2011.06.30.09.08.43\r
28         (version=TLSv1/SSLv3 cipher=OTHER);\r
29         Thu, 30 Jun 2011 09:08:44 -0700 (PDT)\r
30 From: Pieter Praet <pieter@praet.org>\r
31 To: Carl Worth <cworth@cworth.org>, Mark Anderson <ma.skies@gmail.com>,\r
32         Robin Green <greenrd@greenrd.org>\r
33 Subject: [PATCH 2/2] [RFC] possible solution for "Race condition for '*'\r
34         command"\r
35 Date: Thu, 30 Jun 2011 18:08:28 +0200\r
36 Message-Id: <1309450108-2793-2-git-send-email-pieter@praet.org>\r
37 X-Mailer: git-send-email 1.7.4.1\r
38 In-Reply-To: <1309450108-2793-1-git-send-email-pieter@praet.org>\r
39 References: <8739itagad.fsf@yoom.home.cworth.org>\r
40         <1309450108-2793-1-git-send-email-pieter@praet.org>\r
41 Cc: notmuch@notmuchmail.org\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\r
45 List-Id: "Use and development of the notmuch mail system."\r
46         <notmuch.notmuchmail.org>\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
50 List-Post: <mailto:notmuch@notmuchmail.org>\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
54 X-List-Received-Date: Thu, 30 Jun 2011 16:08:46 -0000\r
55 \r
56 `notmuch-search-operate-all' may cause a race condition because\r
57 repeatedly running `notmuch-tag' with the *original* query string\r
58 makes the result list a moving target.\r
59 \r
60 One approach to resolving this, is to feed `notmuch-tag' a static result\r
61 list based on the original query string, instead of the latter itself.\r
62 \r
63 See discussion @ id:"86d3i1d06r.fsf@dragonfly.greenrd.org"\r
64 \r
65 Signed-off-by: Pieter Praet <pieter@praet.org>\r
66 ---\r
67 \r
68 Carl,\r
69 \r
70 I've gone along a different route which assures only matched messages\r
71 are touched, but it does come with quite a performance hit.\r
72 \r
73 Since there isn't a test for the actual race condition(s), I can't be\r
74 sure, but theoretically, at least one of them should be fixed now.\r
75 \r
76 Peace\r
77 \r
78  emacs/notmuch.el |   11 +++++++++--\r
79  1 files changed, 9 insertions(+), 2 deletions(-)\r
80 \r
81 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
82 index f11ec24..84c3ee6 100644\r
83 --- a/emacs/notmuch.el\r
84 +++ b/emacs/notmuch.el\r
85 @@ -845,7 +845,8 @@ Each character of the tag name may consist of alphanumeric\r
86  characters as well as `_.+-'.\r
87  "\r
88    (interactive "sOperation (+add -drop): notmuch tag ")\r
89 -  (let ((action-split (split-string action " +")))\r
90 +  (let ((action-split (split-string action " +"))\r
91 +        (query notmuch-search-query-string))\r
92      ;; Perform some validation\r
93      (let ((words action-split))\r
94        (when (null words) (error "No operation given"))\r
95 @@ -853,7 +854,13 @@ characters as well as `_.+-'.\r
96         (unless (string-match-p "^[-+][-+_.[:word:]]+$" (car words))\r
97           (error "Action must be of the form `+thistag -that_tag'"))\r
98         (setq words (cdr words))))\r
99 -    (apply 'notmuch-tag notmuch-search-query-string action-split)))\r
100 +    (dolist (msgid\r
101 +            (split-string\r
102 +              (with-output-to-string\r
103 +                (with-current-buffer standard-output\r
104 +                  (apply 'call-process notmuch-command nil t nil "search" "--output=messages" (list query))))\r
105 +            "\n+" t))\r
106 +            (apply 'notmuch-tag msgid action-split))))\r
107  \r
108  (defun notmuch-search-buffer-title (query)\r
109    "Returns the title for a buffer with notmuch search results."\r
110 -- \r
111 1.7.4.1\r
112 \r