mwrap (Perl version) user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* [PATCH] set un.sun_len on *BSD systems
@ 2022-12-10 21:11 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2022-12-10 21:11 UTC (permalink / raw)
  To: mwrap-perl

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 {
 	<<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] != ',')

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-10 21:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-10 21:11 [PATCH] set un.sun_len on *BSD systems Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mwrap-perl.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).