From 6dac55bd7c0aa4bcb54da894ffcd80d1f0534134 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 10 Dec 2022 21:11:41 +0000 Subject: set un.sun_len on *BSD systems Maybe this fixes some t/mwrap-httpd.t reliability problems I've noticed on FreeBSD... --- Makefile.PL | 4 +++- mwrap_httpd.h | 4 +++- 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 { </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] != ',') -- cgit v1.2.3-24-ge0c7