mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2025-12-21 21:17:37 -08:00
- 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>
94 lines
2.2 KiB
Diff
94 lines
2.2 KiB
Diff
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 {
|