[PATCH 2/2] [RFC] possible solution for "Race condition for '*' command"
authorPieter Praet <pieter@praet.org>
Thu, 30 Jun 2011 16:08:28 +0000 (18:08 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:38:52 +0000 (09:38 -0800)
34/855bb0fc739f3d447d21418446a38ef18b07d0 [new file with mode: 0644]

diff --git a/34/855bb0fc739f3d447d21418446a38ef18b07d0 b/34/855bb0fc739f3d447d21418446a38ef18b07d0
new file mode 100644 (file)
index 0000000..c2165d5
--- /dev/null
@@ -0,0 +1,112 @@
+Return-Path: <pieter@praet.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id F259A42119E\r
+       for <notmuch@notmuchmail.org>; Thu, 30 Jun 2011 09:08:45 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id R0nER-1lWA9g for <notmuch@notmuchmail.org>;\r
+       Thu, 30 Jun 2011 09:08:45 -0700 (PDT)\r
+Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com\r
+       [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 3A58B42119B\r
+       for <notmuch@notmuchmail.org>; Thu, 30 Jun 2011 09:08:45 -0700 (PDT)\r
+Received: by mail-wy0-f181.google.com with SMTP id 22so1843157wyh.26\r
+       for <notmuch@notmuchmail.org>; Thu, 30 Jun 2011 09:08:45 -0700 (PDT)\r
+Received: by 10.216.160.78 with SMTP id t56mr1020705wek.14.1309450124822;\r
+       Thu, 30 Jun 2011 09:08:44 -0700 (PDT)\r
+Received: from localhost ([109.131.21.173])\r
+       by mx.google.com with ESMTPS id m46sm47142weq.15.2011.06.30.09.08.43\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Thu, 30 Jun 2011 09:08:44 -0700 (PDT)\r
+From: Pieter Praet <pieter@praet.org>\r
+To: Carl Worth <cworth@cworth.org>, Mark Anderson <ma.skies@gmail.com>,\r
+       Robin Green <greenrd@greenrd.org>\r
+Subject: [PATCH 2/2] [RFC] possible solution for "Race condition for '*'\r
+       command"\r
+Date: Thu, 30 Jun 2011 18:08:28 +0200\r
+Message-Id: <1309450108-2793-2-git-send-email-pieter@praet.org>\r
+X-Mailer: git-send-email 1.7.4.1\r
+In-Reply-To: <1309450108-2793-1-git-send-email-pieter@praet.org>\r
+References: <8739itagad.fsf@yoom.home.cworth.org>\r
+       <1309450108-2793-1-git-send-email-pieter@praet.org>\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 30 Jun 2011 16:08:46 -0000\r
+\r
+`notmuch-search-operate-all' may cause a race condition because\r
+repeatedly running `notmuch-tag' with the *original* query string\r
+makes the result list a moving target.\r
+\r
+One approach to resolving this, is to feed `notmuch-tag' a static result\r
+list based on the original query string, instead of the latter itself.\r
+\r
+See discussion @ id:"86d3i1d06r.fsf@dragonfly.greenrd.org"\r
+\r
+Signed-off-by: Pieter Praet <pieter@praet.org>\r
+---\r
+\r
+Carl,\r
+\r
+I've gone along a different route which assures only matched messages\r
+are touched, but it does come with quite a performance hit.\r
+\r
+Since there isn't a test for the actual race condition(s), I can't be\r
+sure, but theoretically, at least one of them should be fixed now.\r
+\r
+Peace\r
+\r
+ emacs/notmuch.el |   11 +++++++++--\r
+ 1 files changed, 9 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index f11ec24..84c3ee6 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -845,7 +845,8 @@ Each character of the tag name may consist of alphanumeric\r
+ characters as well as `_.+-'.\r
+ "\r
+   (interactive "sOperation (+add -drop): notmuch tag ")\r
+-  (let ((action-split (split-string action " +")))\r
++  (let ((action-split (split-string action " +"))\r
++        (query notmuch-search-query-string))\r
+     ;; Perform some validation\r
+     (let ((words action-split))\r
+       (when (null words) (error "No operation given"))\r
+@@ -853,7 +854,13 @@ characters as well as `_.+-'.\r
+       (unless (string-match-p "^[-+][-+_.[:word:]]+$" (car words))\r
+         (error "Action must be of the form `+thistag -that_tag'"))\r
+       (setq words (cdr words))))\r
+-    (apply 'notmuch-tag notmuch-search-query-string action-split)))\r
++    (dolist (msgid\r
++            (split-string\r
++              (with-output-to-string\r
++                (with-current-buffer standard-output\r
++                  (apply 'call-process notmuch-command nil t nil "search" "--output=messages" (list query))))\r
++            "\n+" t))\r
++            (apply 'notmuch-tag msgid action-split))))\r
\r
+ (defun notmuch-search-buffer-title (query)\r
+   "Returns the title for a buffer with notmuch search results."\r
+-- \r
+1.7.4.1\r
+\r