about summary refs log tree commit homepage
path: root/t/httpd-corner.t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-06-24 02:52:53 +0000
committerEric Wong <e@80x24.org>2019-06-24 05:26:27 +0000
commit4e1a84c2a97c319862c960a34e3a7a8bf31d5274 (patch)
tree15ff2c3a3d241bec1ab34eccca73444c2fcdbf85 /t/httpd-corner.t
parentce8cdcd68fd899d28b5d7c0354883b0cb33fc4d6 (diff)
downloadpublic-inbox-4e1a84c2a97c319862c960a34e3a7a8bf31d5274.tar.gz
This Linux-specific option can save us some wakeups during
the TLS negotiation phase, and it can help with ordinary HTTP,
too.

Plain NNTP (and in the future, POP3) are the only things which
require the server send messages, first.
Diffstat (limited to 't/httpd-corner.t')
-rw-r--r--t/httpd-corner.t19
1 files changed, 19 insertions, 0 deletions
diff --git a/t/httpd-corner.t b/t/httpd-corner.t
index c1dc77db..13befcf1 100644
--- a/t/httpd-corner.t
+++ b/t/httpd-corner.t
@@ -36,6 +36,17 @@ my %opts = (
         Listen => 1024,
 );
 my $sock = IO::Socket::INET->new(%opts);
+my $defer_accept_val;
+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());
+        defined $x or die "getsockopt: $!";
+        $defer_accept_val = unpack('i', $x);
+        if ($defer_accept_val <= 0) {
+                die "unexpected TCP_DEFER_ACCEPT value: $defer_accept_val";
+        }
+}
+
 my $upath = "$tmpdir/s";
 my $unix = IO::Socket::UNIX->new(
         Listen => 1024,
@@ -497,6 +508,14 @@ SKIP: {
         is($body, sha1_hex(''), 'read expected body #2');
 }
 
+SKIP: {
+        skip 'TCP_DEFER_ACCEPT is Linux-only', 1 if $^O ne 'linux';
+        my $var = Socket::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');
+};
+
 done_testing();
 
 sub capture {