Zbigniew Szalbot:
> I have just seen this snippet in maillog:
> Sep 29 09:09:11 relay postfix/showq[21060]: warning:
> deferred/3/3559EB80E7: uid 125: file has 2 links

Wietse:
Postfix use the standard rename() function to move mail between incoming,
> active and deferred queues. Depending on the underlying implementation,
> this will result in a brief moment where a file has two names.

Citing from the patch below:

    Workaround for "file has 2 links" warnings in showq. Traditionally,
    UNIX system calls were non-interruptible. This kept kernel code
    simple, but was bad for performance, even on uniprocessors. Solaris
    was relatively early with multi-threading everything, and in 2002/2003
    people were already reporting "file has 2 links" warnings on Solaris.
    Typically what happened was that the showq command would stat a file
    while the queue manager was in the middle of renaming it. If the showq
    command looked at the right moment in time, it could see the file in
    the intermediate state where it had links to the old and new name. We
    now log the warning only when the condition appears to be persistent.

*** ./src/global/mail_open_ok.c-        Wed Sep 20 20:38:11 2000
--- ./src/global/mail_open_ok.c Mon Sep 29 09:10:14 2008
***************
*** 59,64 ****
--- 59,65 ----
  
  #include <sys_defs.h>
  #include <sys/stat.h>
+ #include <time.h>
  #include <errno.h>
  
  /* Utility library. */
***************
*** 102,110 ****
      }
      if ((statp->st_mode & S_IRWXU) != MAIL_QUEUE_STAT_READY)
        return (MAIL_OPEN_NO);
      if (statp->st_nlink > 1) {
!       msg_warn("%s: uid %ld: file has %d links", *path,
!                (long) statp->st_uid, (int) statp->st_nlink);
      }
      return (MAIL_OPEN_YES);
  }
--- 103,130 ----
      }
      if ((statp->st_mode & S_IRWXU) != MAIL_QUEUE_STAT_READY)
        return (MAIL_OPEN_NO);
+ 
+     /*
+      * Workaround for "file has 2 links" warnings in showq. Traditionally,
+      * UNIX system calls were non-interruptible. This kept kernel code
+      * simple, but was bad for performance, even on uniprocessors. Solaris
+      * was relatively early with multi-threading everything, and in 2002/2003
+      * people were already reporting "file has 2 links" warnings on Solaris.
+      * Typically what happened was that the showq command would stat a file
+      * while the queue manager was in the middle of renaming it. If the showq
+      * command looked at the right moment in time, it could see the file in
+      * the intermediate state where it had links to the old and new name. We
+      * now log the warning only when the condition appears to be persistent.
+      */
+ #define MINUTE_SECOND 60                      /* XXX should be centralized */
+ 
      if (statp->st_nlink > 1) {
!       if (msg_verbose)
!           msg_info("%s: uid %ld: file has %d links", *path,
!                    (long) statp->st_uid, (int) statp->st_nlink);
!       else if (statp->st_ctime < time((time_t *) 0) - MINUTE_SECOND)
!           msg_warn("%s: uid %ld: file has %d links", *path,
!                    (long) statp->st_uid, (int) statp->st_nlink);
      }
      return (MAIL_OPEN_YES);
  }

Reply via email to