about summary refs log tree commit
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-01-26 10:29:21 +0000
committerEric Wong <e@yhbt.net>2020-01-28 01:49:48 +0000
commit9689c65f42c0acc9021953b29ce55730c4cd841d (patch)
treeea9e22bbb87efc1a14bb6ac711e3bd53837b9a01 /t
parentddec19694cbf0e1d94fb56c0fc4bd90eae540884 (diff)
downloadpublic-inbox-9689c65f42c0acc9021953b29ce55730c4cd841d.tar.gz
daemon: provide TCP_DEFER_ACCEPT for Perl <5.14
Socket::TCP_DEFER_ACCEPT() did not appear in the Socket module
distributed with Perl until 5.14, despite it being available
since Linux 2.4.
Diffstat (limited to 't')
-rw-r--r--t/httpd-corner.t9
-rw-r--r--t/httpd-https.t2
-rw-r--r--t/httpd.t2
-rw-r--r--t/nntpd-tls.t2
4 files changed, 8 insertions, 7 deletions
diff --git a/t/httpd-corner.t b/t/httpd-corner.t
index 4ed34934..1f2bb53f 100644
--- a/t/httpd-corner.t
+++ b/t/httpd-corner.t
@@ -28,10 +28,11 @@ open(STDIN, '<', '/dev/null') or die 'no /dev/null: $!';
 
 # Make sure we don't clobber socket options set by systemd or similar
 # using socket activation:
-my ($defer_accept_val, $accf_arg);
+my ($defer_accept_val, $accf_arg, $TCP_DEFER_ACCEPT);
 if ($^O eq 'linux') {
-        setsockopt($sock, IPPROTO_TCP, Socket::TCP_DEFER_ACCEPT(), 5) or die;
-        my $x = getsockopt($sock, IPPROTO_TCP, Socket::TCP_DEFER_ACCEPT());
+        $TCP_DEFER_ACCEPT = eval { Socket::TCP_DEFER_ACCEPT() } // 9;
+        setsockopt($sock, IPPROTO_TCP, $TCP_DEFER_ACCEPT, 5) or die;
+        my $x = getsockopt($sock, IPPROTO_TCP, $TCP_DEFER_ACCEPT);
         defined $x or die "getsockopt: $!";
         $defer_accept_val = unpack('i', $x);
         if ($defer_accept_val <= 0) {
@@ -526,7 +527,7 @@ SKIP: {
 
 SKIP: {
         skip 'TCP_DEFER_ACCEPT is Linux-only', 1 if $^O ne 'linux';
-        my $var = Socket::TCP_DEFER_ACCEPT();
+        my $var = $TCP_DEFER_ACCEPT;
         defined(my $x = getsockopt($sock, IPPROTO_TCP, $var)) or die;
         is(unpack('i', $x), $defer_accept_val,
                 'TCP_DEFER_ACCEPT unchanged if previously set');
diff --git a/t/httpd-https.t b/t/httpd-https.t
index 9ce060c8..ee5ced0f 100644
--- a/t/httpd-https.t
+++ b/t/httpd-https.t
@@ -87,7 +87,7 @@ for my $args (
 
         SKIP: {
                 skip 'TCP_DEFER_ACCEPT is Linux-only', 2 if $^O ne 'linux';
-                my $var = Socket::TCP_DEFER_ACCEPT();
+                my $var = eval { Socket::TCP_DEFER_ACCEPT() } // 9;
                 defined(my $x = getsockopt($https, IPPROTO_TCP, $var)) or die;
                 ok(unpack('i', $x) > 0, 'TCP_DEFER_ACCEPT set on https');
         };
diff --git a/t/httpd.t b/t/httpd.t
index 880c69e6..2972afb2 100644
--- a/t/httpd.t
+++ b/t/httpd.t
@@ -81,7 +81,7 @@ EOF
 
 SKIP: {
         skip 'TCP_DEFER_ACCEPT is Linux-only', 1 if $^O ne 'linux';
-        my $var = Socket::TCP_DEFER_ACCEPT();
+        my $var = eval { Socket::TCP_DEFER_ACCEPT() } // 9;
         defined(my $x = getsockopt($sock, IPPROTO_TCP, $var)) or die;
         ok(unpack('i', $x) > 0, 'TCP_DEFER_ACCEPT set');
 };
diff --git a/t/nntpd-tls.t b/t/nntpd-tls.t
index edc1fab4..c97d179d 100644
--- a/t/nntpd-tls.t
+++ b/t/nntpd-tls.t
@@ -174,7 +174,7 @@ for my $args (
 
         SKIP: {
                 skip 'TCP_DEFER_ACCEPT is Linux-only', 2 if $^O ne 'linux';
-                my $var = Socket::TCP_DEFER_ACCEPT();
+                my $var = eval { Socket::TCP_DEFER_ACCEPT() } // 9;
                 defined(my $x = getsockopt($nntps, IPPROTO_TCP, $var)) or die;
                 ok(unpack('i', $x) > 0, 'TCP_DEFER_ACCEPT set on NNTPS');
                 defined($x = getsockopt($starttls, IPPROTO_TCP, $var)) or die;