gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] branch master updated (2a59d367 -> 1f796283


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] branch master updated (2a59d367 -> 1f796283)
Date: Sun, 02 Jun 2019 18:20:45 +0200

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 2a59d367 configure: Fixed 'getsockname' detection with special 
compiler flags
     new 2db0eabd configure: fixed detection of 'getsockname' on some systems 
(W32 x32), do not use 'getsockname()' if it is not detected by configure.
     new 2c93aa35 Added .gitattributes, fixed line endings in ac_define_dir.m4, 
updated ac_define_dir.m4 to new version.
     new 20eceebc Properly handle port detection if AF_UNIX socket is used on 
*BSD, macOS
     new a58870f6 configure: check for 'rand' and 'random' by MHD_CHECK_FUNC
     new 1f796283 Added support for SOCK_NOSIGPIPE from Solaris 11.4 and NetBSD 
7+

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitattributes               |  4 +++
 configure.ac                 | 58 ++++++++++++++++++++------------
 m4/ac_define_dir.m4          | 69 +++++++++++++++++++-------------------
 m4/mhd_check_func.m4         | 80 ++++++++++++++++++++++++++++++++++++++++++++
 src/microhttpd/daemon.c      | 12 ++++++-
 src/microhttpd/mhd_sockets.c | 25 +++++++++++---
 src/microhttpd/mhd_sockets.h |  8 ++++-
 7 files changed, 193 insertions(+), 63 deletions(-)
 create mode 100644 .gitattributes
 create mode 100644 m4/mhd_check_func.m4

diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000..cb45bd1f
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,4 @@
+*.m4   eol=lf
+configure.ac   eol=lf
+makefile.am    eol=lf
+.gitattributes eol=lf
diff --git a/configure.ac b/configure.ac
index 203b9d30..928a21b8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -772,7 +772,23 @@ AC_CHECK_HEADERS([zlib.h],[have_zlib=yes],[have_zlib=no], 
[AC_INCLUDES_DEFAULT])
 AM_CONDITIONAL([HAVE_ZLIB], [[test "x$have_zlib" = xyes]])
 
 # Check for generic functions
-AC_CHECK_FUNCS([rand random])
+MHD_CHECK_FUNC([random],
+  [
+AC_INCLUDES_DEFAULT
+[#include <stdlib.h>
+  ]],
+  [[long int r = random(); (void)r;]],
+  [],
+  [
+    MHD_CHECK_FUNC([rand],
+      [
+AC_INCLUDES_DEFAULT
+[#include <stdlib.h>
+      ]],
+      [[int r = rand(); (void)r;]],
+       )
+  ]
+)
 
 AC_CHECK_MEMBERS([struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len, 
                   struct sockaddr_storage.ss_len],
@@ -789,12 +805,25 @@ AC_CHECK_MEMBERS([struct sockaddr_in.sin_len, struct 
sockaddr_in6.sin6_len,
 #endif
    ])
 
-AC_CHECK_DECLS([getsockname],
+MHD_CHECK_FUNC([getsockname],
+  [[
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
+  ]],
   [
-   AC_CHECK_FUNCS([getsockname],
-     [
-      AC_CACHE_CHECK([[whether getsockname() is usable]], 
[[mhc_cv_getsockname_usable]],
-        [
+    struct sockaddr_storage ss;
+    (void)getsockname(socket(0,0,0),(struct sockaddr *)&ss,(void*)0);
+  ],
+  [
+    AC_CACHE_CHECK([[whether getsockname() is usable]], 
[[mhc_cv_getsockname_usable]],
+      [
          AC_RUN_IFELSE(
            [
             AC_LANG_SOURCE(
@@ -888,22 +917,9 @@ int main(void)
          )
         ]
       )
-      AS_VAR_IF([[mhc_cv_getsockname_usable]], [["no"]], [:],
+    AS_VAR_IF([[mhc_cv_getsockname_usable]], [["no"]], [:],
         [AC_DEFINE([[MHD_USE_GETSOCKNAME]], [[1]], [Define if you have usable 
`getsockname' function.])])
-     ]
-   )
-  ], [],
-  [[
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
-  ]]
+  ]
 )
 
 # Check for inter-thread signaling type
diff --git a/m4/ac_define_dir.m4 b/m4/ac_define_dir.m4
index f7e028fc..e15cea2c 100644
--- a/m4/ac_define_dir.m4
+++ b/m4/ac_define_dir.m4
@@ -1,35 +1,34 @@
-dnl @synopsis AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION])
-dnl
-dnl This macro _AC_DEFINEs VARNAME to the expansion of the DIR
-dnl variable, taking care of fixing up ${prefix} and such.
-dnl
-dnl VARNAME is offered as both a C preprocessor symbol, and an output
-dnl variable.
-dnl
-dnl Note that the 3 argument form is only supported with autoconf 2.13
-dnl and later (i.e. only where _AC_DEFINE supports 3 arguments).
-dnl
-dnl Examples:
-dnl
-dnl    AC_DEFINE_DIR(DATADIR, datadir)
-dnl    AC_DEFINE_DIR(PROG_PATH, bindir, [Location of installed binaries])
-dnl
-dnl @category Misc
-dnl @author Stepan Kasal <address@hidden>
-dnl @author Andreas Schwab <address@hidden>
-dnl @author Guido Draheim <address@hidden>
-dnl @author Alexandre Oliva
-dnl @version 2005-01-17
-dnl @license AllPermissive
-
-AC_DEFUN([AC_DEFINE_DIR], [
-  prefix_NONE=
-  exec_prefix_NONE=
-  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
-  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
-  eval ac_define_dir="\"[$]$2\""
-  AC_SUBST($1, "$ac_define_dir")
-  AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3])
-  test "$prefix_NONE" && prefix=NONE
-  test "$exec_prefix_NONE" && exec_prefix=NONE
-])
+dnl @synopsis AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION])
+dnl
+dnl This macro sets VARNAME to the expansion of the DIR variable,
+dnl taking care of fixing up ${prefix} and such.
+dnl
+dnl VARNAME is then offered as both an output variable and a C
+dnl preprocessor symbol.
+dnl
+dnl Example:
+dnl
+dnl    AC_DEFINE_DIR([DATADIR], [datadir], [Where data are placed to.])
+dnl
+dnl @category Misc
+dnl @author Stepan Kasal <address@hidden>
+dnl @author Andreas Schwab <address@hidden>
+dnl @author Guido U. Draheim <address@hidden>
+dnl @author Alexandre Oliva
+dnl @version 2006-10-13
+dnl @license AllPermissive
+
+AC_DEFUN([AC_DEFINE_DIR], [
+  prefix_NONE=
+  exec_prefix_NONE=
+  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
+  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
+dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn
+dnl refers to ${prefix}.  Thus we have to use `eval' twice.
+  eval ac_define_dir="\"[$]$2\""
+  eval ac_define_dir="\"$ac_define_dir\""
+  AC_SUBST($1, "$ac_define_dir")
+  AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3])
+  test "$prefix_NONE" && prefix=NONE
+  test "$exec_prefix_NONE" && exec_prefix=NONE
+])
diff --git a/m4/mhd_check_func.m4 b/m4/mhd_check_func.m4
new file mode 100644
index 00000000..983d0306
--- /dev/null
+++ b/m4/mhd_check_func.m4
@@ -0,0 +1,80 @@
+# SYNOPSIS
+#
+#   MHD_CHECK_FUNC([FUNCTION_NAME],
+#                  [INCLUDES=AC_INCLUDES_DEFAULT], [CHECK_CODE],
+#                  [ACTION-IF-AVAILABLE], [ACTION-IF-NOT-AVAILABLE],
+#                  [ADDITIONAL_LIBS])
+#
+# DESCRIPTION
+#
+#   This macro checks for presence of specific function by including
+#   specified headers and compiling and linking CHECK_CODE.
+#   This check both declaration and presence in library.
+#   Unlike AC_CHECK_FUNCS macro, this macro do not produce false
+#   negative result if function is declared with specific calling
+#   conventions like __stdcall' or attribute like
+#   __attribute__((__dllimport__)) and linker failed to build test
+#   program if library contains function with calling conventions
+#   different from declared. 
+#   By using definition from provided headers, this macro ensures that
+#   correct calling convention is used for detection.
+#
+#   Example usage:
+#
+#     MHD_CHECK_FUNC([memmem],
+#                    [[#include <string.h>]],
+#                    [const void *ptr = memmem("aa", 2, "a", 1); (void)ptr;],
+#                    [var_use_memmem='yes'], [var_use_memmem='no'])
+#
+#   Defined cache variable used in check so if any test will not work
+#   correctly on some platform, user may simply fix it by giving cache
+#   variable in configure parameters, for example:
+#
+#     ./configure mhd_cv_func_memmem_have=no
+#
+#   This simplify building from source on exotic platforms as patching
+#   of configure.ac is not required to change results of tests.
+#
+# LICENSE
+#
+#   Copyright (c) 2019 Karlson2k (Evgeny Grin) <address@hidden>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 1
+
+AC_DEFUN([MHD_CHECK_FUNC],[dnl
+  AC_PREREQ([2.64])dnl for AS_VAR_IF, m4_ifblank, m4_ifnblank
+  m4_ifblank(m4_translit([$1],[()],[  ]), [m4_fatal([First macro argument must 
not be empty])])dnl
+  m4_ifblank([$3], [m4_fatal([Third macro argument must not be empty])])dnl
+  m4_bmatch(m4_normalize([$1]), [\s],dnl
+            [m4_fatal([First macro argument must not contain whitespaces])])dnl
+  m4_if(m4_index([$3], m4_normalize(m4_translit([$1],[()],[  ]))), [-1], dnl
+        [m4_fatal([CHECK_CODE parameter (third macro argument) do not contain 
']m4_normalize([$1])[' token])])dnl
+  AS_VAR_PUSHDEF([cv_Var], 
[mhd_cv_func_]m4_bpatsubst(m4_normalize(m4_translit([$1],[()],[  
])),[[^a-zA-Z0-9]],[_]))dnl
+  dnl
+  AC_CACHE_CHECK([for function $1], [cv_Var],
+    [dnl
+      m4_ifnblank([$6],[dnl
+        mhd_check_func_SAVE_LIBS="$LIBS"
+        LIBS="$LIBS m4_normalize([$6])"
+      ])dnl
+      AC_LINK_IFELSE(
+        [AC_LANG_PROGRAM([m4_default_nblank([$2],[AC_INCLUDES_DEFAULT])], 
[$3]) ],
+        [AS_VAR_SET([cv_Var],["yes"])], [AS_VAR_SET([cv_Var],["no"])] ) 
+      m4_ifnblank([$6],[dnl
+        LIBS="${mhd_check_func_SAVE_LIBS}"
+        AS_UNSET([mhd_check_func_SAVE_LIBS])
+      ])dnl
+    ])
+  AS_VAR_IF([cv_Var], ["yes"],
+            
[AC_DEFINE([[HAVE_]]m4_bpatsubst(m4_toupper(m4_normalize(m4_translit([$1],[()],[
  ]))),[[^A-Z0-9]],[_]),
+                       [1], [Define to 1 if you have the 
`]m4_normalize(m4_translit([$1],[()],[  ]))[' function.])
+            m4_n([$4])dnl
+            ], [$5])
+  AS_VAR_POPDEF([cv_Var])dnl
+])
+
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index fdca4de2..0764f286 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -3136,7 +3136,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
   s = accept4 (fd,
                addr,
                &addrlen,
-               MAYBE_SOCK_CLOEXEC | MAYBE_SOCK_NONBLOCK);
+               MAYBE_SOCK_CLOEXEC | MAYBE_SOCK_NONBLOCK | 
MAYBE_SOCK_NOSIGPIPE);
   sk_nonbl = (MAYBE_SOCK_NONBLOCK != 0);
 #else  /* ! USE_ACCEPT4 */
   s = accept (fd,
@@ -6092,6 +6092,7 @@ MHD_start_daemon_va (unsigned int flags,
       listen_fd = daemon->listen_fd;
     }
 
+#ifdef HAVE_GETSOCKNAME
   if ( (0 == daemon->port) &&
        (0 == (*pflags & MHD_USE_NO_LISTEN_SOCKET)) )
     { /* Get port number. */
@@ -6123,6 +6124,14 @@ MHD_start_daemon_va (unsigned int flags,
                     _("Failed to get listen port number (`struct 
sockaddr_storage` too small!?)\n"));
 #endif /* HAVE_MESSAGES */
         }
+#ifndef __linux__
+      else if (0 == addrlen)
+        {
+          /* Many non-Linux-based platforms return zero addrlen
+           * for AF_UNIX sockets */
+          daemon->port = 0; /* special value for UNIX domain sockets */
+        }
+#endif /* __linux__ */
 #endif /* MHD_POSIX_SOCKETS */
       else
         {
@@ -6160,6 +6169,7 @@ MHD_start_daemon_va (unsigned int flags,
           }
         }
     }
+#endif /* HAVE_GETSOCKNAME */
 
   if ( (MHD_INVALID_SOCKET != listen_fd) &&
        (! MHD_socket_nonblocking_ (listen_fd)) )
diff --git a/src/microhttpd/mhd_sockets.c b/src/microhttpd/mhd_sockets.c
index 3504dc26..04405945 100644
--- a/src/microhttpd/mhd_sockets.c
+++ b/src/microhttpd/mhd_sockets.c
@@ -507,12 +507,18 @@ MHD_socket_create_listen_ (int pf)
 {
   MHD_socket fd;
   int cloexec_set;
+#if defined(SOCK_NOSIGPIPE) || defined(MHD_socket_nosignal_)
+  int nosigpipe_set;
+#endif /* SOCK_NOSIGPIPE ||  MHD_socket_nosignal_ */
 
-#if defined(MHD_POSIX_SOCKETS) && defined(SOCK_CLOEXEC)
+#if defined(MHD_POSIX_SOCKETS) && ( defined(SOCK_CLOEXEC) || 
defined(SOCK_NOSIGPIPE) )
   fd = socket (pf,
-               SOCK_STREAM | SOCK_CLOEXEC,
+               SOCK_STREAM | SOCK_CLOEXEC | MAYBE_SOCK_NOSIGPIPE,
                0);
-  cloexec_set = !0;
+  cloexec_set = (MAYBE_SOCK_CLOEXEC != 0);
+#if defined(SOCK_NOSIGPIPE) || defined(MHD_socket_nosignal_)
+  nosigpipe_set = (MAYBE_SOCK_NOSIGPIPE != 0);
+#endif /* SOCK_NOSIGPIPE ||  MHD_socket_nosignal_ */
 #elif defined(MHD_WINSOCK_SOCKETS) && defined (WSA_FLAG_NO_HANDLE_INHERIT)
   fd = WSASocketW (pf,
                    SOCK_STREAM,
@@ -533,15 +539,24 @@ MHD_socket_create_listen_ (int pf)
     }
   if (MHD_INVALID_SOCKET == fd)
     return MHD_INVALID_SOCKET;
+
+#if defined(SOCK_NOSIGPIPE) || defined(MHD_socket_nosignal_)
+  if ( ( (! nosigpipe_set)
 #ifdef MHD_socket_nosignal_
-  if(! MHD_socket_nosignal_(fd))
+         || (! MHD_socket_nosignal_(fd))
+#endif /* MHD_socket_nosignal_ */
+       ) && (0 == MAYBE_MSG_NOSIGNAL) )
     {
+      /* SIGPIPE disable is possible on this platform
+       * (so application expect that it will be disabled),
+       * but failed to be disabled here and it is not
+       * possible to disable SIGPIPE by MSG_NOSIGNAL. */
       const int err = MHD_socket_get_error_ ();
       (void) MHD_socket_close_ (fd);
       MHD_socket_fset_error_ (err);
       return MHD_INVALID_SOCKET;
     }
-#endif /* MHD_socket_nosignal_ */
+#endif /* SOCK_NOSIGPIPE ||  MHD_socket_nosignal_ */
   if (! cloexec_set)
     (void) MHD_socket_noninheritable_ (fd);
 
diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h
index 8663edd3..62ea46d5 100644
--- a/src/microhttpd/mhd_sockets.h
+++ b/src/microhttpd/mhd_sockets.h
@@ -162,6 +162,12 @@
 #  define MAYBE_SOCK_NONBLOCK 0
 #endif /* ! HAVE_SOCK_NONBLOCK */
 
+#ifdef SOCK_NOSIGPIPE
+#  define MAYBE_SOCK_NOSIGPIPE SOCK_NOSIGPIPE
+#else  /* ! HAVE_SOCK_NONBLOCK */
+#  define MAYBE_SOCK_NOSIGPIPE 0
+#endif /* ! HAVE_SOCK_NONBLOCK */
+
 #ifdef MSG_NOSIGNAL
 #  define MAYBE_MSG_NOSIGNAL MSG_NOSIGNAL
 #else  /* ! MSG_NOSIGNAL */
@@ -178,7 +184,7 @@
 #  define SHUT_RDWR SD_BOTH
 #endif
 
-#if HAVE_ACCEPT4+0 != 0 && (defined(HAVE_SOCK_NONBLOCK) || 
defined(SOCK_CLOEXEC))
+#if HAVE_ACCEPT4+0 != 0 && (defined(HAVE_SOCK_NONBLOCK) || 
defined(SOCK_CLOEXEC) || defined(SOCK_NOSIGPIPE))
 #  define USE_ACCEPT4 1
 #endif
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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