Explorar el Código

test_client_put_stop: check 'net.inet.tcp.blackhole' value

Evgeny Grin (Karlson2k) hace 4 años
padre
commit
43938f8d41
Se han modificado 2 ficheros con 44 adiciones y 10 borrados
  1. 13 0
      configure.ac
  2. 31 10
      src/microhttpd/test_client_put_stop.c

+ 13 - 0
configure.ac

@@ -1918,6 +1918,19 @@ MHD_CHECK_FUNC([[sysctl]], [[
   ]], [[int mib[2] = {CTL_KERN, KERN_MAXPROC}; if (sysctl(mib, 2, NULL, NULL, NULL, 0)) return 1;]]
 )
 
+MHD_CHECK_FUNC([[sysctlbyname]], [[
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SYSCTL_H
+#include <sys/sysctl.h>
+#endif
+#ifdef HAVE_STDDEF_H
+#include <stddef.h>
+#endif
+  ]], [[sysctlbyname("test", NULL, NULL, NULL, 0);]]
+)
+
 MHD_CHECK_FUNC([[usleep]], [[#include <unistd.h>]], [[usleep(100000);]])
 MHD_CHECK_FUNC([[nanosleep]], [[#include <time.h>]], [[struct timespec ts2, ts1 = {0, 0}; nanosleep(&ts1, &ts2);]])
 

+ 31 - 10
src/microhttpd/test_client_put_stop.c

@@ -269,17 +269,29 @@ static unsigned int rate_limiter;   /**< Maximum number of checks per second */
 static void
 test_global_init (void)
 {
-  if (MHD_YES != MHD_is_feature_supported (MHD_FEATURE_AUTOSUPPRESS_SIGPIPE))
+  rate_limiter = 0;
+#ifdef HAVE_SYSCTLBYNAME
+  if (use_hard_close)
   {
-#if defined(HAVE_SIGNAL_H) && defined(SIGPIPE)
-    if (SIG_ERR == signal (SIGPIPE, SIG_IGN))
-      externalErrorExitDesc ("Error suppressing SIGPIPE signal");
-#else /* ! HAVE_SIGNAL_H || ! SIGPIPE */
-    fprintf (stderr, "Cannot suppress SIGPIPE signal.\n");
-    /* exit (77); */
-#endif
+    int blck_hl;
+    size_t blck_hl_size = sizeof (blck_hl);
+    if (0 == sysctlbyname ("net.inet.tcp.blackhole", &blck_hl, &blck_hl_size,
+                           NULL, 0))
+    {
+      if (2 <= blck_hl)
+      {
+        fprintf (stderr, "'sysctl net.inet.tcp.blackhole = %d', test is "
+                 "unreliable with this system setting, skipping.\n", blck_hl);
+        exit (77);
+      }
+    }
+    else
+    {
+      if (ENOENT != errno)
+        externalErrorExitDesc ("Cannot get 'net.inet.tcp.blackhole' value");
+    }
   }
-  rate_limiter = 0;
+#endif
 #if defined(HAVE_SYSCTL) && defined(CTL_NET) && defined(PF_INET) && \
   defined(IPPROTO_ICMP) && defined(ICMPCTL_ICMPLIM)
   if (use_hard_close)
@@ -329,7 +341,16 @@ test_global_init (void)
   }
 #endif /* HAVE_SYSCTL && CTL_NET && PF_INET &&
           IPPROTO_ICMP && ICMPCTL_ICMPLIM */
-
+  if (MHD_YES != MHD_is_feature_supported (MHD_FEATURE_AUTOSUPPRESS_SIGPIPE))
+  {
+#if defined(HAVE_SIGNAL_H) && defined(SIGPIPE)
+    if (SIG_ERR == signal (SIGPIPE, SIG_IGN))
+      externalErrorExitDesc ("Error suppressing SIGPIPE signal");
+#else /* ! HAVE_SIGNAL_H || ! SIGPIPE */
+    fprintf (stderr, "Cannot suppress SIGPIPE signal.\n");
+    /* exit (77); */
+#endif
+  }
 }