emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r113421: * filelock.c (create_lock_file) [!HAVE_MKOS


From: Paul Eggert
Subject: [Emacs-diffs] trunk r113421: * filelock.c (create_lock_file) [!HAVE_MKOSTEMP && !HAVE_MKSTEMP]:
Date: Sun, 14 Jul 2013 23:12:45 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113421
revision-id: address@hidden
parent: address@hidden
author: Paul Eggert  <address@hidden>
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Sun 2013-07-14 16:12:42 -0700
message:
  * filelock.c (create_lock_file) [!HAVE_MKOSTEMP && !HAVE_MKSTEMP]:
  
  Simplify by making this case like the other two.  This is a bit
  slower on obsolete hosts, but the extra complexity isn't worth it.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/filelock.c                 filelock.c-20091113204419-o5vbwnq5f7feedwu-179
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-07-14 00:30:45 +0000
+++ b/src/ChangeLog     2013-07-14 23:12:42 +0000
@@ -1,5 +1,9 @@
 2013-07-14  Paul Eggert  <address@hidden>
 
+       * filelock.c (create_lock_file) [!HAVE_MKOSTEMP && !HAVE_MKSTEMP]:
+       Simplify by making this case like the other two.  This is a bit
+       slower on obsolete hosts, but the extra complexity isn't worth it.
+
        * callproc.c (child_setup, relocate_fd) [!DOS_NT]:
        * process.c (create_process) [!DOS_NT]:
        Remove now-unnecessary calls to emacs_close.

=== modified file 'src/filelock.c'
--- a/src/filelock.c    2013-07-09 06:29:29 +0000
+++ b/src/filelock.c    2013-07-14 23:12:42 +0000
@@ -412,8 +412,6 @@
       USE_SAFE_ALLOCA;
       char *nonce = SAFE_ALLOCA (lfdirlen + sizeof nonce_base);
       int fd;
-      bool need_fchmod;
-      mode_t world_readable = S_IRUSR | S_IRGRP | S_IROTH;
       memcpy (nonce, lfname, lfdirlen);
       strcpy (nonce + lfdirlen, nonce_base);
 
@@ -421,17 +419,14 @@
       /* Prefer mkostemp to mkstemp, as it avoids a window where FD is
         temporarily open without close-on-exec.  */
       fd = mkostemp (nonce, O_BINARY | O_CLOEXEC);
-      need_fchmod = 1;
 #elif HAVE_MKSTEMP
       /* Prefer mkstemp to mktemp, as it avoids a race between
         mktemp and emacs_open.  */
       fd = mkstemp (nonce);
-      need_fchmod = 1;
 #else
       mktemp (nonce);
       fd = emacs_open (nonce, O_WRONLY | O_CREAT | O_EXCL | O_BINARY,
-                      world_readable);
-      need_fchmod = 0;
+                      S_IRUSR | S_IWUSR);
 #endif
 
       if (fd < 0)
@@ -445,7 +440,7 @@
          lock_info_len = strlen (lock_info_str);
          err = 0;
          if (emacs_write (fd, lock_info_str, lock_info_len) != lock_info_len
-             || (need_fchmod && fchmod (fd, world_readable) != 0))
+             || fchmod (fd, S_IRUSR | S_IRGRP | S_IROTH) != 0)
            err = errno;
          /* There is no need to call fsync here, as the contents of
             the lock file need not survive system crashes.  */


reply via email to

[Prev in Thread] Current Thread [Next in Thread]