mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2025-12-21 21:17:37 -08:00
www-servers/pound: tests: use forks instead of threads
- The test harness perl script for pound uses threads for socket listeners, requiring PERL_FEATURES="ithreads". - To avoid forcing users to rebuild all perl, replace threads by forks of the main process. Signed-off-by: Philipp Rösner <rndxelement@protonmail.com> Part-of: https://github.com/gentoo/gentoo/pull/44136 Closes: https://github.com/gentoo/gentoo/pull/44136 Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
parent
494732c61a
commit
e315b5fc03
93
www-servers/pound/files/pound-4.16-test-threads.patch
Normal file
93
www-servers/pound/files/pound-4.16-test-threads.patch
Normal file
@ -0,0 +1,93 @@
|
||||
Replace usage of threads for socket listeners by forks of the
|
||||
main process in order to avoid requiring perl built with
|
||||
PERL_FEATURES="ithreads".
|
||||
The added return values are necessary because otherwise
|
||||
the process (before the thread) would continue it's procedure
|
||||
call chain (before, the thread exited, not executing any more
|
||||
code).
|
||||
|
||||
--- a/tests/poundharness.pl
|
||||
+++ b/tests/poundharness.pl
|
||||
@@ -16,8 +16,6 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use Socket qw(:DEFAULT :crlf);
|
||||
-use threads;
|
||||
-use threads::shared;
|
||||
use Getopt::Long;
|
||||
use HTTP::Tiny;
|
||||
use POSIX qw(:sys_wait_h);
|
||||
@@ -90,7 +88,6 @@ sub cleanup {
|
||||
## -----------------------------------
|
||||
|
||||
my %status_codes;
|
||||
-share(%status_codes);
|
||||
|
||||
$SIG{QUIT} = $SIG{HUP} = $SIG{TERM} = $SIG{INT} = \&cleanup;
|
||||
|
||||
@@ -1542,19 +1539,16 @@ sub read_and_process {
|
||||
my $self = shift;
|
||||
|
||||
foreach my $lst (@{$self->{listeners}}) {
|
||||
- $lst->listen;
|
||||
- }
|
||||
-
|
||||
- foreach my $lst (@{$self->{listeners}}) {
|
||||
- threads->create(sub {
|
||||
- my $lst = shift;
|
||||
+ my $pid = fork();
|
||||
+ if ($pid == 0) {
|
||||
$lst->listen;
|
||||
while (1) {
|
||||
- my $fh;
|
||||
- accept($fh, $lst->socket_handle) or threads->exit();
|
||||
- process_http_request($fh, $lst)
|
||||
+ my $fh;
|
||||
+ accept($fh, $lst->socket_handle) or last;
|
||||
+ process_http_request($fh, $lst)
|
||||
}
|
||||
- }, $lst)->detach;
|
||||
+ exit 0;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1595,7 +1589,7 @@ sub process_http_request {
|
||||
|
||||
local $| = 1;
|
||||
my $http = HTTPServ->new($sock, $backend);
|
||||
- $http->parse();
|
||||
+ return unless $http->parse();
|
||||
if ($http->uri =~ m{^/([^/]+)(/.*)?}) {
|
||||
my ($dir, $rest) = ($1, $2);
|
||||
if (my $ep = $endpoints{$dir}) {
|
||||
@@ -1658,7 +1652,8 @@ sub getline {
|
||||
sub ParseRequest {
|
||||
my $http = shift;
|
||||
|
||||
- my $input = $http->getline() or threads->exit();
|
||||
+ my $input = $http->getline();
|
||||
+ return 0 unless defined $input;
|
||||
# print "GOT $input\n";
|
||||
my @res = split " ", $input;
|
||||
if (@res != 3) {
|
||||
@@ -1666,6 +1661,7 @@ sub ParseRequest {
|
||||
}
|
||||
|
||||
($http->{METHOD}, $http->{URI}, $http->{VERSION}) = @res;
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
sub ParseHeader {
|
||||
@@ -1703,9 +1699,10 @@ sub GetBody {
|
||||
|
||||
sub parse {
|
||||
my $http = shift;
|
||||
- $http->ParseRequest;
|
||||
+ return 0 unless $http->ParseRequest;
|
||||
$http->ParseHeader;
|
||||
$http->GetBody;
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
sub reply {
|
||||
84
www-servers/pound/files/pound-4.17-test-threads.patch
Normal file
84
www-servers/pound/files/pound-4.17-test-threads.patch
Normal file
@ -0,0 +1,84 @@
|
||||
Replace usage of threads for socket listeners by forks of the
|
||||
main process in order to avoid requiring perl built with
|
||||
PERL_FEATURES="ithreads".
|
||||
The added return values are necessary because otherwise
|
||||
the process (before the thread) would continue it's procedure
|
||||
call chain (before, the thread exited, not executing any more
|
||||
code).
|
||||
|
||||
--- a/tests/poundharness.pl
|
||||
+++ b/tests/poundharness.pl
|
||||
@@ -16,7 +16,6 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use Socket qw(:DEFAULT :crlf);
|
||||
-use threads;
|
||||
use Getopt::Long;
|
||||
use HTTP::Tiny;
|
||||
use POSIX qw(:sys_wait_h);
|
||||
@@ -1619,19 +1618,16 @@ sub read_and_process {
|
||||
my $self = shift;
|
||||
|
||||
foreach my $lst (@{$self->{listeners}}) {
|
||||
- $lst->listen;
|
||||
- }
|
||||
-
|
||||
- foreach my $lst (@{$self->{listeners}}) {
|
||||
- threads->create(sub {
|
||||
- my $lst = shift;
|
||||
+ my $pid = fork();
|
||||
+ if ($pid == 0) {
|
||||
$lst->listen;
|
||||
while (1) {
|
||||
- my $fh;
|
||||
- accept($fh, $lst->socket_handle) or threads->exit();
|
||||
- process_http_request($fh, $lst)
|
||||
+ my $fh;
|
||||
+ accept($fh, $lst->socket_handle) or last;
|
||||
+ process_http_request($fh, $lst)
|
||||
}
|
||||
- }, $lst)->detach;
|
||||
+ exit 0;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1694,7 +1690,7 @@ sub process_http_request {
|
||||
|
||||
local $| = 1;
|
||||
my $http = HTTPServ->new($sock, $backend);
|
||||
- $http->parse();
|
||||
+ return unless $http->parse();
|
||||
if ($http->uri =~ m{^/([^/]+)(/.*)?}) {
|
||||
my ($dir, $rest) = ($1, $2);
|
||||
if (my $ep = $endpoints{$dir}) {
|
||||
@@ -1757,7 +1753,8 @@ sub getline {
|
||||
sub ParseRequest {
|
||||
my $http = shift;
|
||||
|
||||
- my $input = $http->getline() or threads->exit();
|
||||
+ my $input = $http->getline();
|
||||
+ return 0 unless defined $input;
|
||||
# print "GOT $input\n";
|
||||
my @res = split " ", $input;
|
||||
if (@res != 3) {
|
||||
@@ -1765,6 +1762,7 @@ sub ParseRequest {
|
||||
}
|
||||
|
||||
($http->{METHOD}, $http->{URI}, $http->{VERSION}) = @res;
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
sub ParseHeader {
|
||||
@@ -1802,9 +1800,10 @@ sub GetBody {
|
||||
|
||||
sub parse {
|
||||
my $http = shift;
|
||||
- $http->ParseRequest;
|
||||
+ return 0 unless $http->ParseRequest;
|
||||
$http->ParseHeader;
|
||||
$http->GetBody;
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
sub reply {
|
||||
@ -38,6 +38,10 @@ BDEPEND="
|
||||
)
|
||||
"
|
||||
|
||||
PATCHES=(
|
||||
"${FILESDIR}"/${P}-test-threads.patch
|
||||
)
|
||||
|
||||
src_configure() {
|
||||
local myconf=(
|
||||
--disable-dynamic-backends
|
||||
|
||||
@ -38,6 +38,10 @@ BDEPEND="
|
||||
)
|
||||
"
|
||||
|
||||
PATCHES=(
|
||||
"${FILESDIR}"/${P}-test-threads.patch
|
||||
)
|
||||
|
||||
src_configure() {
|
||||
local myconf=(
|
||||
--disable-dynamic-backends
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user