Re: `notmuch setup` replaces `~/.notmuch-config` instead of truncating it
authorCiprian Dorin, Craciun <ciprian.craciun@gmail.com>
Tue, 16 Nov 2010 22:16:07 +0000 (00:16 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:37:32 +0000 (09:37 -0800)
06/b2ef080ae71ac108fbf58b28afa58ea780b235 [new file with mode: 0644]

diff --git a/06/b2ef080ae71ac108fbf58b28afa58ea780b235 b/06/b2ef080ae71ac108fbf58b28afa58ea780b235
new file mode 100644 (file)
index 0000000..c2a38ef
--- /dev/null
@@ -0,0 +1,121 @@
+Return-Path: <ciprian.craciun@gmail.com>\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 7E0BE40DEE1\r
+       for <notmuch@notmuchmail.org>; Tue, 16 Nov 2010 14:16:48 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.999\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.999 tagged_above=-999 required=5\r
+       tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,\r
+       DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001]\r
+       autolearn=ham\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 I8XP+6lIek8Q for <notmuch@notmuchmail.org>;\r
+       Tue, 16 Nov 2010 14:16:38 -0800 (PST)\r
+Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com\r
+       [209.85.216.181])\r
+       by olra.theworths.org (Postfix) with ESMTP id 4467C40DDF7\r
+       for <notmuch@notmuchmail.org>; Tue, 16 Nov 2010 14:16:38 -0800 (PST)\r
+Received: by qyk4 with SMTP id 4so1355983qyk.5\r
+       for <notmuch@notmuchmail.org>; Tue, 16 Nov 2010 14:16:37 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=domainkey-signature:received:mime-version:received:in-reply-to\r
+       :references:from:date:message-id:subject:to:content-type\r
+       :content-transfer-encoding;\r
+       bh=N5XOx7UxMxSDd2/C6+5bOuPr51dvItjhawtKsoQo4Vw=;\r
+       b=kaEGlw1znjeVUwiqjrH+USN9hdfzxPx7uM1jMVVT1AS04FtwULf+A9A1KHVJF87Iok\r
+       +EmfFhGZmOjR3ilXvpxM9HXpvksgo2pD9ZYFluIHuBWnUlEu/mEuMc4BZ2nlHbLPOGi8\r
+       NPNuIB9i6eilWKJwnM1Rw+N0aglxuF9vbRLn4=\r
+DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
+       h=mime-version:in-reply-to:references:from:date:message-id:subject:to\r
+       :content-type:content-transfer-encoding;\r
+       b=ssAnyYVkTQoLsaRD9fqjzSUIB1U3bvaFif92qtqqtCxIvT1U2USDR6UQfF52X2YI9S\r
+       K8IaHB6wsWvC4UnPEkL1gn/NFnxv9dPAXqe3vFaaAAIT5q36lYCYQgDs7uq7fWiQe4cX\r
+       E0DDloqmX7zxiu4tHAXnLZeLk+ZI4sh9q5pXs=\r
+Received: by 10.229.232.211 with SMTP id jv19mr6794076qcb.28.1289945797700;\r
+       Tue, 16 Nov 2010 14:16:37 -0800 (PST)\r
+MIME-Version: 1.0\r
+Received: by 10.229.189.17 with HTTP; Tue, 16 Nov 2010 14:16:07 -0800 (PST)\r
+In-Reply-To: <4CE2EB89.5040209@fifthhorseman.net>\r
+References: <AANLkTikKiKC716H+ddF0Q5T0xc=vGHHOVroLRwzO3ujV@mail.gmail.com>\r
+       <87sjz1dr0j.fsf@yoom.home.cworth.org>\r
+       <AANLkTikrXdp5OOCw2Avs8ao9Ukpq8szsdP9FFZP+eYNK@mail.gmail.com>\r
+       <4CE2EB89.5040209@fifthhorseman.net>\r
+From: "Ciprian Dorin, Craciun" <ciprian.craciun@gmail.com>\r
+Date: Wed, 17 Nov 2010 00:16:07 +0200\r
+Message-ID: <AANLkTikMhb=x4jOhOwjP4Ytd+h=4f247ZnA3A0GOS=hC@mail.gmail.com>\r
+Subject: Re: `notmuch setup` replaces `~/.notmuch-config` instead of\r
+       truncating it\r
+To: notmuch <notmuch@notmuchmail.org>\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: quoted-printable\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: Tue, 16 Nov 2010 22:16:48 -0000\r
+\r
+On Tue, Nov 16, 2010 at 22:37, Daniel Kahn Gillmor\r
+<dkg@fifthhorseman.net> wrote:\r
+> On 11/16/2010 03:26 PM, Ciprian Dorin, Craciun wrote:\r
+>> =C2=A0 =C2=A0 P.S.: I say "pseudo" atomic because only the rename is ato=\r
+mic,\r
+>> thus in order to override file `a` for the target file `b` which\r
+>> exists, we must execute two **non-atomic** operations as a whole, but\r
+>> each atomic in part, rename operations: make `b` -> `c`, and then\r
+>> rename `a` -> `b`. So there is actually a small time-frame when I can\r
+>> be left with two files (`a` and `c`), none of which is my config file\r
+>> `b`. (This can be solved when opening the config file by checking if\r
+>> there isn't any leftover `c` or `a` file, in which case I take the `a`\r
+>> file and complete the rename.)\r
+>\r
+> There is only one ".notmuch-config" entry in the inode directory that is\r
+> your homedir. =C2=A0it points either to the old file, or the new file. =\r
+=C2=A0it\r
+> cannot point to both, and it will not point to anything but those two\r
+> possibilities. =C2=A0This is what the atomicity of the operation is expec=\r
+ted\r
+> to guarantee.\r
+>\r
+> =C2=A0 =C2=A0 =C2=A0 =C2=A0--dkg\r
+\r
+\r
+    Actually I've been wrong about this... I've thought that the way\r
+the file is "overwritten" is actually done by either two `rename`\r
+calls or by `link`, followed by another `link`, and then finally an\r
+`unlink` (this is what I've tried to explain in my previous email).\r
+\r
+    In fact I've thought that the `rename` OS call can't overwrite a\r
+file if it exists.\r
+\r
+    But after reading the man page of `rename(2)` -- quoted below -- I\r
+was indeed wrong to call the atomicity as being "pseudo".\r
+\r
+~~~~\r
+       int rename(const char *oldpath, const char *newpath);\r
+...\r
+       If newpath already exists it will be atomically replaced\r
+(subject to a few conditions; see ERRORS below),  so  that  there  is\r
+no\r
+       point at which another process attempting to access newpath\r
+will find it missing.\r
+...\r
+       If newpath exists but the operation fails for some reason\r
+rename() guarantees to leave an instance of newpath in place.\r
+~~~~\r
+\r
+    So indeed the behavior is completely atomic.\r
+\r
+    Ciprian.\r