]> granicus.if.org Git - mutt/commitdiff
Remove extra lstats() in safe_rename() upon link success.
authorKevin McCarthy <kevin@8t8.us>
Wed, 29 Aug 2018 20:00:14 +0000 (13:00 -0700)
committerKevin McCarthy <kevin@8t8.us>
Wed, 29 Aug 2018 20:00:14 +0000 (13:00 -0700)
I originally kept the lstat()'s in order to make as few changes as
possible to the function.  However, Derek Martin argues correctly that
if we are trusting the link() 0-retval, the lstats are unnecessary and
in fact can cause a performance impact over NFS.

lib.c

diff --git a/lib.c b/lib.c
index 1c8b8682be3d8d805f19126b7710055a000b2369..345d3be110cdbaa0a01f0438cc6ae64e22f562b4 100644 (file)
--- a/lib.c
+++ b/lib.c
@@ -519,17 +519,24 @@ int safe_rename (const char *src, const char *target)
     return -1;
   }
 
+  /*
+   * Remove the compare_stat() check, because it causes problems with maildir on
+   * filesystems that don't properly support hard links, such as
+   * sshfs.  The filesystem creates the link, but the resulting file
+   * is given a different inode number by the sshfs layer.  This
+   * results in an infinite loop creating links.
+   */
+#if 0
   /*
    * Stat both links and check if they are equal.
    */
-  
   if (lstat (src, &ssb) == -1)
   {
     dprint (1, (debugfile, "safe_rename: can't stat %s: %s (%d)\n",
                src, strerror (errno), errno));
     return -1;
   }
-  
+
   if (lstat (target, &tsb) == -1)
   {
     dprint (1, (debugfile, "safe_rename: can't stat %s: %s (%d)\n",
@@ -541,15 +548,6 @@ int safe_rename (const char *src, const char *target)
    * pretend that the link failed because the target file
    * did already exist.
    */
-
-#if 0
-  /*
-   * Remove this check, because it causes problems with maildir on
-   * filesystems that don't properly support hard links, such as
-   * sshfs.  The filesystem creates the link, but the resulting file
-   * is given a different inode number by the sshfs layer.  This
-   * results in an infinite loop creating links.
-   */
   if (compare_stat (&ssb, &tsb) == -1)
   {
     dprint (1, (debugfile, "safe_rename: stat blocks for %s and %s diverge; pretending EEXIST.\n", src, target));