Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perlPackages.NetServerSSPrefork: init at 0.06pre #56267

Merged
merged 2 commits into from Oct 15, 2020
Merged

Conversation

catern
Copy link
Contributor

@catern catern commented Feb 23, 2019

Motivation for this change

This is an optional dependency of Starman which was previously not included. If you try to use the Server::Starter compatibility of Starman, it crashes on trying to import this package.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@catern
Copy link
Contributor Author

catern commented Jun 16, 2019

Note that this is depended on by Hydra; adding this dependency makes it possible to use this functionality of Starman with Hydra, which was previously broken.

Pinging @volth for review of Perl, @grahamc and @edolstra for relevance to Hydra

@catern
Copy link
Contributor Author

catern commented Jul 2, 2019

@volth ping on Perl? @grahamc @edolstra ping on Hydra-relevance?

pkgs/top-level/perl-packages.nix Outdated Show resolved Hide resolved
@JohnAZoidberg
Copy link
Member

JohnAZoidberg commented Jul 16, 2019

Please rebase onto latest master.

@catern
Copy link
Contributor Author

catern commented Aug 9, 2019

Rebased on latest master and updated TestUNIXSock version to latest available (0.4)

@JohnAZoidberg
Copy link
Member

Would this work as well?
https://metacpan.org/pod/release/RHANDOM/Net-Server-0.97/lib/Net/Server/PreFork.pm

Is the package you're using on cpan?

@catern
Copy link
Contributor Author

catern commented Aug 9, 2019

I'm not sure what you mean by "work". That's a different package with different functionality.

The package I'm using is on CPAN. It's here: https://metacpan.org/pod/Net::Server::SS::PreFork

As I commented in my commit adding the package (which I should have pasted here):

This package hasn't seen a release in about 9 years, and there are
important features on master (namely, Unix socket support), so we'll
get our version from Github.

@aanderse
Copy link
Member

ping (triage)

@catern
Copy link
Contributor Author

catern commented Apr 4, 2020

Rebased onto latest master. Still think this should be fine to merge.

@catern
Copy link
Contributor Author

catern commented Apr 5, 2020

Changed the version number to 0.06pre on volth's suggestion to avoid breaking the auto-updater

@catern catern changed the title perlPackages.NetServerSSPrefork: init at 5fccc0c270 perlPackages.NetServerSSPrefork: init at 0.06pre Apr 9, 2020
@catern
Copy link
Contributor Author

catern commented Apr 9, 2020

Fixed the conflict with master

@stale
Copy link

stale bot commented Oct 13, 2020

Hello, I'm a bot and I thank you in the name of the community for your contributions.

Nixpkgs is a busy repository, and unfortunately sometimes PRs get left behind for too long. Nevertheless, we'd like to help committers reach the PRs that are still important. This PR has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.

If this is still important to you and you'd like to remove the stale label, we ask that you leave a comment. Your comment can be as simple as "still important to me". But there's a bit more you can do:

If you received an approval by an unprivileged maintainer and you are just waiting for a merge, you can @ mention someone with merge permissions and ask them to help. You might be able to find someone relevant by using Git blame on the relevant files, or via GitHub's web interface. You can see if someone's a member of the nixpkgs-committers team, by hovering with the mouse over their username on the web interface, or by searching them directly on the list.

If your PR wasn't reviewed at all, it might help to find someone who's perhaps a user of the package or module you are changing, or alternatively, ask once more for a review by the maintainer of the package/module this is about. If you don't know any, you can use Git blame on the relevant files, or GitHub's web interface to find someone who touched the relevant files in the past.

If your PR has had reviews and nevertheless got stale, make sure you've responded to all of the reviewer's requests / questions. Usually when PR authors show responsibility and dedication, reviewers (privileged or not) show dedication as well. If you've pushed a change, it's possible the reviewer wasn't notified about your push via email, so you can always officially request them for a review, or just @ mention them and say you've addressed their comments.

Lastly, you can always ask for help at our Discourse Forum, or more specifically, at this thread or at #nixos' IRC channel.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 13, 2020
@catern
Copy link
Contributor Author

catern commented Oct 13, 2020

Still important to me... This should be fine to merge, I think

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 13, 2020
@aanderse aanderse requested a review from stigtsp October 13, 2020 23:18
Copy link
Member

@stigtsp stigtsp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK in principle, but would like a few changes:

EDIT: My main concern is adding it to propagatedBuildInputs for Starman and the effects (if any) this might have on hydra.

pkgs/top-level/perl-packages.nix Show resolved Hide resolved
pkgs/top-level/perl-packages.nix Show resolved Hide resolved
@stigtsp
Copy link
Member

stigtsp commented Oct 14, 2020

Couldn't find any direct link between Net::Server:SS::PreFork on CPAN and the GitHub repo in this PR, so did a quick review of the code differences between https://cpan.metacpan.org/authors/id/K/KA/KAZUHO/Net-Server-SS-PreFork-0.05.tar.gz and https://github.com/kazuho/p5-Net-Server-SS-PreFork/archive/5fccc0c270e25c65ef634304630af74b48807d21.zip.

Looks legit to me.

Diff for posterity included:

$ rm -r Net-Server-SS-PreFork-0.05/inc; diff -pru --new-file Net-Server-SS-PreFork-0.05 p5-Net-Server-SS-PreFork-5fccc0c270e25c65ef634304630af74b48807d21/
diff -pru --new-file Net-Server-SS-PreFork-0.05/lib/Net/Server/SS/PreFork.pm p5-Net-Server-SS-PreFork-5fccc0c270e25c65ef634304630af74b48807d21/lib/Net/Server/SS/PreFork.pm
--- Net-Server-SS-PreFork-0.05/lib/Net/Server/SS/PreFork.pm	2010-02-22 02:33:20.000000000 +0100
+++ p5-Net-Server-SS-PreFork-5fccc0c270e25c65ef634304630af74b48807d21/lib/Net/Server/SS/PreFork.pm	2017-06-08 19:26:51.000000000 +0200
@@ -5,6 +5,7 @@ use warnings;
 
 use Net::Server::PreFork;
 use Net::Server::Proto::TCP;
+use Net::Server::Proto::UNIX;
 use Server::Starter qw(server_ports);
 
 use base qw(Net::Server::PreFork);
@@ -17,15 +18,22 @@ sub pre_bind {
     
     my %ports = %{server_ports()};
     for my $port (sort keys %ports) {
-        my $sock = Net::Server::Proto::TCP->new();
-        if ($port =~ /^(.*):(.*?)$/) {
-            $sock->NS_host($1);
-            $sock->NS_port($2);
+        my $sock;
+        if ($port =~ /^(.*):(.*?)$/ || $port =~ /^[0-9]+$/s) {
+            $sock = Net::Server::Proto::TCP->new();
+            $sock->NS_proto('TCP');
+            if ($port =~ /^(.*):(.*?)$/) {
+              $sock->NS_host($1);
+              $sock->NS_port($2);
+            } else {
+              $sock->NS_host('*');
+              $sock->NS_port($port);
+            }
         } else {
-            $sock->NS_host('*');
+            $sock = Net::Server::Proto::UNIX->new();
+            $sock->NS_proto('UNIX');
             $sock->NS_port($port);
         }
-        $sock->NS_proto('TCP');
         $sock->fdopen($ports{$port}, 'r')
             or $self->fatal("failed to bind listening socket:$ports{$port}:$!");
         push @{$prop->{sock}}, $sock;
diff -pru --new-file Net-Server-SS-PreFork-0.05/Makefile.PL p5-Net-Server-SS-PreFork-5fccc0c270e25c65ef634304630af74b48807d21/Makefile.PL
--- Net-Server-SS-PreFork-0.05/Makefile.PL	2010-02-16 04:56:12.000000000 +0100
+++ p5-Net-Server-SS-PreFork-5fccc0c270e25c65ef634304630af74b48807d21/Makefile.PL	2017-06-08 19:26:51.000000000 +0200
@@ -10,6 +10,7 @@ requires 'Net::Server';
 requires 'Server::Starter' => 0.02;
 test_requires 'LWP::Simple';
 test_requires 'Test::TCP' => 0.06;
+test_requires 'Test::UNIXSock';
 test_requires 'HTTP::Server::Simple::CGI';
 
 auto_include;
diff -pru --new-file Net-Server-SS-PreFork-0.05/MANIFEST p5-Net-Server-SS-PreFork-5fccc0c270e25c65ef634304630af74b48807d21/MANIFEST
--- Net-Server-SS-PreFork-0.05/MANIFEST	2010-02-22 02:34:21.000000000 +0100
+++ p5-Net-Server-SS-PreFork-5fccc0c270e25c65ef634304630af74b48807d21/MANIFEST	1970-01-01 01:00:00.000000000 +0100
@@ -1,24 +0,0 @@
-Changes
-inc/HTTP/Server/Simple/CGI.pm
-inc/LWP/Simple.pm
-inc/Module/AutoInstall.pm
-inc/Module/Install.pm
-inc/Module/Install/AutoInstall.pm
-inc/Module/Install/Base.pm
-inc/Module/Install/Can.pm
-inc/Module/Install/Fetch.pm
-inc/Module/Install/Include.pm
-inc/Module/Install/Makefile.pm
-inc/Module/Install/Metadata.pm
-inc/Module/Install/Win32.pm
-inc/Module/Install/WriteAll.pm
-inc/Test/TCP.pm
-lib/Net/Server/SS/PreFork.pm
-Makefile.PL
-MANIFEST			This list of files
-META.yml
-README
-t/00-base.t
-t/01-httpd.pl
-t/01-httpd.t
-t/02-multiport.t
diff -pru --new-file Net-Server-SS-PreFork-0.05/MANIFEST.SKIP p5-Net-Server-SS-PreFork-5fccc0c270e25c65ef634304630af74b48807d21/MANIFEST.SKIP
--- Net-Server-SS-PreFork-0.05/MANIFEST.SKIP	1970-01-01 01:00:00.000000000 +0100
+++ p5-Net-Server-SS-PreFork-5fccc0c270e25c65ef634304630af74b48807d21/MANIFEST.SKIP	2017-06-08 19:26:51.000000000 +0200
@@ -0,0 +1,21 @@
+\bRCS\b
+\bCVS\b
+^MANIFEST\.
+^Makefile$
+~$
+^#
+\.old$
+^blib/
+^pm_to_blib
+^MakeMaker-\d
+\.gz$
+\.cvsignore
+^t/9\d_.*\.t
+^t/perlcritic
+^tools/
+\.svn/
+^[^/]+\.yaml$
+^[^/]+\.pl$
+^\.shipit$
+\.git
+nytprof/
diff -pru --new-file Net-Server-SS-PreFork-0.05/META.yml p5-Net-Server-SS-PreFork-5fccc0c270e25c65ef634304630af74b48807d21/META.yml
--- Net-Server-SS-PreFork-0.05/META.yml	2010-02-22 02:34:06.000000000 +0100
+++ p5-Net-Server-SS-PreFork-5fccc0c270e25c65ef634304630af74b48807d21/META.yml	1970-01-01 01:00:00.000000000 +0100
@@ -1,28 +0,0 @@
----
-abstract: 'a hot-deployable variant of Net::Server::PreFork'
-author:
-  - 'Kazuho Oku'
-build_requires:
-  ExtUtils::MakeMaker: 6.42
-  HTTP::Server::Simple::CGI: 0
-  LWP::Simple: 0
-  Test::TCP: 0.06
-configure_requires:
-  ExtUtils::MakeMaker: 6.42
-distribution_type: module
-generated_by: 'Module::Install version 0.93'
-license: perl
-meta-spec:
-  url: http://module-build.sourceforge.net/META-spec-v1.4.html
-  version: 1.4
-name: Net-Server-SS-PreFork
-no_index:
-  directory:
-    - inc
-    - t
-requires:
-  Net::Server: 0
-  Server::Starter: 0.02
-resources:
-  license: http://dev.perl.org/licenses/
-version: 0.05
diff -pru --new-file Net-Server-SS-PreFork-0.05/t/03-unix.pl p5-Net-Server-SS-PreFork-5fccc0c270e25c65ef634304630af74b48807d21/t/03-unix.pl
--- Net-Server-SS-PreFork-0.05/t/03-unix.pl	1970-01-01 01:00:00.000000000 +0100
+++ p5-Net-Server-SS-PreFork-5fccc0c270e25c65ef634304630af74b48807d21/t/03-unix.pl	2017-06-08 19:26:51.000000000 +0200
@@ -0,0 +1,28 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+
+use lib qw(blib/lib lib);
+
+my $server = MyServer->new()->run();
+
+package MyServer;
+
+use base qw( Net::Server::SS::PreFork );
+use Server::Starter qw(server_ports);
+
+sub new {
+  my ($class) = @_;
+
+  return $class->SUPER::new({
+    proto => 'unix',
+    port  => (values %{Server::Starter::server_ports()})[0],
+  });
+}
+
+sub process_request {
+  print getppid, "\n";
+}
+
+1;
diff -pru --new-file Net-Server-SS-PreFork-0.05/t/03-unix.t p5-Net-Server-SS-PreFork-5fccc0c270e25c65ef634304630af74b48807d21/t/03-unix.t
--- Net-Server-SS-PreFork-0.05/t/03-unix.t	1970-01-01 01:00:00.000000000 +0100
+++ p5-Net-Server-SS-PreFork-5fccc0c270e25c65ef634304630af74b48807d21/t/03-unix.t	2017-06-08 19:26:51.000000000 +0200
@@ -0,0 +1,38 @@
+use strict;
+use warnings;
+
+use LWP::Simple;
+use Test::UNIXSock;
+use Test::More tests => 3;
+use IO::Socket::UNIX;
+
+use Server::Starter qw(start_server);
+
+test_unix_sock(
+    server => sub {
+        my $path = shift;
+        start_server(
+            path => $path,
+            exec => [ $^X, qw(t/03-unix.pl) ],
+        );
+    },
+    client => sub {
+        my ($path, $server_pid) = @_;
+        sleep 1;
+        my $socket = IO::Socket::UNIX->new(
+          Peer => $path,
+        ) or die "failed to connect to unix socket:$!";
+        chomp(my $worker_pid = <$socket>);
+        like($worker_pid, qr/^\d+$/, 'send request and get pid');
+        $socket->close;
+        kill 'HUP', $server_pid;
+        sleep 5;
+        $socket = IO::Socket::UNIX->new(
+          Peer => $path,
+        ) or die "failed to connect to unix socket:$!";
+        chomp(my $new_worker_pid = <$socket>);
+        like($new_worker_pid, qr/^\d+$/, 'send request and get pid');
+        isnt($worker_pid, $new_worker_pid, 'worker pid changed');
+        $socket->close;
+    },
+);

@stigtsp
Copy link
Member

stigtsp commented Oct 14, 2020

@GrahamcOfBorg build perlPackages.NetServerSSPrefork perldevelPackages.NetServerSSPrefork

@stigtsp
Copy link
Member

stigtsp commented Oct 15, 2020

@GrahamcOfBorg test hydra

@stigtsp
Copy link
Member

stigtsp commented Oct 15, 2020

@catern Can you rebase against master again?

This package hasn't seen a release in about 9 years, and there are
important features on master (namely, Unix socket support), so we'll
get our version from Github.
@catern
Copy link
Contributor Author

catern commented Oct 15, 2020

Yes, rebased. (There were no conflicts)

Copy link
Member

@stigtsp stigtsp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Result of nixpkgs-review pr 56267 1

13 packages built:
  • hydra-migration
  • hydra-unstable
  • nix-serve
  • perl530Packages.CatalystXScriptServerStarman
  • perl530Packages.NetServerSSPrefork
  • perl530Packages.Starman
  • perl530Packages.TaskPlack
  • perl530Packages.TestUNIXSock
  • perl532Packages.CatalystXScriptServerStarman
  • perl532Packages.NetServerSSPrefork
  • perl532Packages.Starman
  • perl532Packages.TaskPlack
  • perl532Packages.TestUNIXSock

@stigtsp stigtsp merged commit fd2995d into NixOS:master Oct 15, 2020
@catern
Copy link
Contributor Author

catern commented Oct 15, 2020

Amazing, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants