about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <mwrap-perl@80x24.org>2022-12-10 21:11:41 +0000
committerEric Wong <mwrap-perl@80x24.org>2022-12-11 06:31:16 +0000
commit6dac55bd7c0aa4bcb54da894ffcd80d1f0534134 (patch)
treebc0f3c6eccc13ecb8b0bae5a2de36080bccd5577
parentdb566af1407bc769d65e2294ec8f1d48e1bd7d9d (diff)
downloadmwrap-6dac55bd7c0aa4bcb54da894ffcd80d1f0534134.tar.gz
Maybe this fixes some t/mwrap-httpd.t reliability problems I've
noticed on FreeBSD...
-rw-r--r--Makefile.PL4
-rw-r--r--mwrap_httpd.h4
2 files changed, 6 insertions, 2 deletions
diff --git a/Makefile.PL b/Makefile.PL
index 3f1200b..6f563c1 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -104,6 +104,8 @@ push @writemakefile_args, (
 
 WriteMakefile(@writemakefile_args);
 
+my $tflags = $ccflags;
+$tflags .= ' -DHAS_SOCKADDR_SA_LEN ' if $Config{d_sockaddr_sa_len};
 sub MY::postamble {
         <<EOF;
 N = \$\$(( \$\$(nproc 2>/dev/null || gnproc 2>/dev/null || echo 2) + 1 ))
@@ -114,7 +116,7 @@ check-manifest :: MANIFEST
 
 build.env :: Makefile
         echo >\$\@+ extra_linker_flags=$LIBS -lpthread
-        echo >>\$\@+ extra_compiler_flags=-I. $INC $Config{ccflags} $ccflags
+        echo >>\$\@+ extra_compiler_flags=-I. $INC $Config{ccflags} $tflags
         mv \$\@+ \$\@
 
 pure_all :: build.env
diff --git a/mwrap_httpd.h b/mwrap_httpd.h
index 13ac256..5c5a58b 100644
--- a/mwrap_httpd.h
+++ b/mwrap_httpd.h
@@ -942,7 +942,9 @@ static void h1d_event_step(struct mw_h1d *h1d)
 static int h1d_init(struct mw_h1d *h1d, const char *menv)
 {
         union mw_sockaddr sa = { .un = { .sun_family = AF_UNIX } };
-
+#ifdef HAS_SOCKADDR_SA_LEN
+        sa.un.sun_len = (unsigned char)sizeof(struct sockaddr_un);
+#endif
         const char *env = strstr(menv, "socket_dir:");
         if (!env) return 1;
         if (env != menv && env[-1] != ',')