[Pkg-gnupg-commit] [gpgme] 78/103: core: Allow disabling the use of SYS_getdents for Linux.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Thu Dec 14 18:53:06 UTC 2017


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gpgme.

commit 4632adf403611b50be2b4e852a4607070935d0e5
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Oct 4 18:03:54 2017 +0200

    core: Allow disabling the use of SYS_getdents for Linux.
    
    * configure.ac (USE_LINUX_GETDENTS): New ac_define.  Add option
    --disable-linux-getdents.
    * src/posix-io.c: Make use of USE_LINUX_GETDENTS.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>
---
 configure.ac   | 21 +++++++++++++++++++++
 src/posix-io.c | 14 ++++++++------
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1284317..6859357 100644
--- a/configure.ac
+++ b/configure.ac
@@ -762,7 +762,28 @@ fi
 AM_CONDITIONAL(HAVE_UISERVER, test "$uiserver" != "no")
 
 
+# Option --disable-linux-getdents
+#
+# By default we use SYS_getdents on Linux to optimize fd closing
+# before an exec.  This option allows to switch this optimization off.
+use_linux_getdents=yes
+AC_ARG_ENABLE(linux-getdents,
+              AC_HELP_STRING([--disable-linux-getdents],
+                             [do not use SYS_getdents on Linux]),
+              use_linux_getdents=$enableval)
+if test "$use_linux_getdents" = "yes"; then
+    case "${host}" in
+        *-*-linux*)
+           AC_DEFINE(USE_LINUX_GETDENTS,1,
+                     [Defined if SYS_getdents can be used on Linux])
+           ;;
+    esac
+fi
+
+
+#
 # Add a few constants to help porting to W32
+#
 AH_VERBATIM([SEPCONSTANTS],
 [
 /* Separators as used in $PATH and file name.  */
diff --git a/src/posix-io.c b/src/posix-io.c
index 4267713..9b7b181 100644
--- a/src/posix-io.c
+++ b/src/posix-io.c
@@ -47,11 +47,11 @@
 #include <ctype.h>
 #include <sys/resource.h>
 
-#if __linux__
+#ifdef USE_LINUX_GETDENTS
 # include <sys/syscall.h>
 # include <sys/types.h>
 # include <dirent.h>
-#endif /*__linux__ */
+#endif /*USE_LINUX_GETDENTS*/
 
 
 #include "util.h"
@@ -60,6 +60,7 @@
 #include "ath.h"
 #include "debug.h"
 
+
 

 void
 _gpgme_io_subsystem_init (void)
@@ -280,7 +281,7 @@ _gpgme_io_set_nonblocking (int fd)
 }
 
 
-#ifdef __linux__
+#ifdef USE_LINUX_GETDENTS
 /* This is not declared in public headers; getdents(2) says that we must
  * define it ourselves.  */
 struct linux_dirent
@@ -292,7 +293,8 @@ struct linux_dirent
 };
 
 # define DIR_BUF_SIZE 1024
-#endif /* __linux__ */
+#endif /*USE_LINUX_GETDENTS*/
+
 
 static long int
 get_max_fds (void)
@@ -310,7 +312,7 @@ get_max_fds (void)
    * fork and exec in a multi-threaded process because opendir uses
    * malloc and thus a mutex which may deadlock with a malloc in another
    * thread.  However, the underlying getdents system call is safe.  */
-#ifdef __linux__
+#ifdef USE_LINUX_GETDENTS
   {
     int dir_fd;
     char dir_buf[DIR_BUF_SIZE];
@@ -356,7 +358,7 @@ get_max_fds (void)
         source = "/proc";
       }
     }
-#endif /* __linux__ */
+#endif /*USE_LINUX_GETDENTS*/
 
 #ifdef RLIMIT_NOFILE
   if (fds == -1)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gpgme.git



More information about the Pkg-gnupg-commit mailing list