commit 43938f8d41e3f1680afcfb30d1f2cbf95a0e0483
parent 1a7fb032ba128c81136f92ce4cd71449916a0486
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Mon, 6 Dec 2021 21:26:06 +0300
test_client_put_stop: check 'net.inet.tcp.blackhole' value
Diffstat:
2 files changed, 44 insertions(+), 10 deletions(-)
diff --git a/configure.ac b/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);]])
diff --git a/src/microhttpd/test_client_put_stop.c b/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
+ }
}