Hello community, here is the log from the commit of package perl-Test-TCP for openSUSE:Factory checked in at 2019-10-08 19:57:16 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Test-TCP (Old) and /work/SRC/openSUSE:Factory/.perl-Test-TCP.new.2352 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Test-TCP" Tue Oct 8 19:57:16 2019 rev:16 rq:735810 version:2.21 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Test-TCP/perl-Test-TCP.changes 2019-08-19 21:27:23.528646251 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Test-TCP.new.2352/perl-Test-TCP.changes 2019-10-08 19:57:19.012307717 +0200 @@ -1,0 +2,9 @@ +Fri Oct 4 09:41:51 UTC 2019 - <timueller+p...@suse.de> + +- updated to 2.21 + see /usr/share/doc/packages/perl-Test-TCP/Changes + + 2.21 2019-10-03T03:15:22Z + - Fix race condition in check_port(UDP) #78 + +------------------------------------------------------------------- Old: ---- Test-TCP-2.20.tar.gz New: ---- Test-TCP-2.21.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Test-TCP.spec ++++++ --- /var/tmp/diff_new_pack.zln1uG/_old 2019-10-08 19:57:19.716305608 +0200 +++ /var/tmp/diff_new_pack.zln1uG/_new 2019-10-08 19:57:19.720305597 +0200 @@ -17,14 +17,14 @@ Name: perl-Test-TCP -Version: 2.20 +Version: 2.21 Release: 0 %define cpan_name Test-TCP Summary: Testing TCP program License: Artistic-1.0 OR GPL-1.0-or-later Group: Development/Libraries/Perl Url: https://metacpan.org/release/%{cpan_name} -Source0: https://cpan.metacpan.org/authors/id/M/MI/MIYAGAWA/%{cpan_name}-%{version}.tar.gz +Source0: https://cpan.metacpan.org/authors/id/K/KA/KAZUHO/%{cpan_name}-%{version}.tar.gz Source1: cpanspec.yml BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ Test-TCP-2.20.tar.gz -> Test-TCP-2.21.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-TCP-2.20/Changes new/Test-TCP-2.21/Changes --- old/Test-TCP-2.20/Changes 2019-08-04 00:48:29.000000000 +0200 +++ new/Test-TCP-2.21/Changes 2019-10-03 05:15:51.000000000 +0200 @@ -1,5 +1,8 @@ Revision history for Perl module Test::TCP +2.21 2019-10-03T03:15:22Z + - Fix race condition in check_port(UDP) #78 + 2.20 2019-08-03T22:47:58Z - Fix test for . not in @INC by default #58 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-TCP-2.20/META.json new/Test-TCP-2.21/META.json --- old/Test-TCP-2.20/META.json 2019-08-04 00:48:29.000000000 +0200 +++ new/Test-TCP-2.21/META.json 2019-10-03 05:15:51.000000000 +0200 @@ -4,7 +4,7 @@ "Tokuhiro Matsuno <tokuhi...@gmail.com>" ], "dynamic_config" : 0, - "generated_by" : "Minilla/v3.1.4", + "generated_by" : "Minilla/v3.1.6", "license" : [ "perl_5" ], @@ -37,7 +37,7 @@ "Perl::Critic" : "1.105", "Test::CPAN::Meta" : "0", "Test::MinimumVersion::Fast" : "0.04", - "Test::PAUSE::Permissions" : "0.04", + "Test::PAUSE::Permissions" : "0.07", "Test::Perl::Critic" : "1.02", "Test::Pod" : "1.41", "Test::Spellunker" : "v0.2.7" @@ -67,7 +67,7 @@ }, "Test::TCP" : { "file" : "lib/Test/TCP.pm", - "version" : "2.20" + "version" : "2.21" }, "Test::TCP::CheckPort" : { "file" : "lib/Test/TCP/CheckPort.pm" @@ -84,7 +84,7 @@ "web" : "https://github.com/tokuhirom/Test-TCP" } }, - "version" : "2.20", + "version" : "2.21", "x_contributors" : [ "Alex Vandiver <a...@chmrr.net>", "Andrii Melnykov <andy.melni...@gmail.com>", @@ -116,5 +116,6 @@ "yappo <yappo@d0d07461-0603-4401-acd4-de1884942a52>", "奥 一穂 <kaz...@em114-48-138-123.pool.e-mobile.ne.jp>" ], + "x_serialization_backend" : "JSON::PP version 2.97001", "x_static_install" : 1 } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-TCP-2.20/META.yml new/Test-TCP-2.21/META.yml --- old/Test-TCP-2.20/META.yml 2019-08-04 00:48:29.000000000 +0200 +++ new/Test-TCP-2.21/META.yml 2019-10-03 05:15:51.000000000 +0200 @@ -9,7 +9,7 @@ configure_requires: ExtUtils::MakeMaker: '6.64' dynamic_config: 0 -generated_by: 'Minilla/v3.1.4, CPAN::Meta::Converter version 2.143240' +generated_by: 'Minilla/v3.1.6, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -30,7 +30,7 @@ file: lib/Net/EmptyPort.pm Test::TCP: file: lib/Test/TCP.pm - version: '2.20' + version: '2.21' Test::TCP::CheckPort: file: lib/Test/TCP/CheckPort.pm requires: @@ -44,7 +44,7 @@ bugtracker: https://github.com/tokuhirom/Test-TCP/issues homepage: https://github.com/tokuhirom/Test-TCP repository: git://github.com/tokuhirom/Test-TCP.git -version: '2.20' +version: '2.21' x_contributors: - 'Alex Vandiver <a...@chmrr.net>' - 'Andrii Melnykov <andy.melni...@gmail.com>' @@ -75,4 +75,5 @@ - 'richard.leach <richard.le...@nccgroup.com>' - 'yappo <yappo@d0d07461-0603-4401-acd4-de1884942a52>' - '奥 一穂 <kaz...@em114-48-138-123.pool.e-mobile.ne.jp>' +x_serialization_backend: 'CPAN::Meta::YAML version 0.018' x_static_install: 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-TCP-2.20/Makefile.PL new/Test-TCP-2.21/Makefile.PL --- old/Test-TCP-2.20/Makefile.PL 2019-08-04 00:48:29.000000000 +0200 +++ new/Test-TCP-2.21/Makefile.PL 2019-10-03 05:15:51.000000000 +0200 @@ -11,7 +11,7 @@ my %WriteMakefileArgs = ( NAME => 'Test::TCP', DISTNAME => 'Test-TCP', - VERSION => '2.20', + VERSION => '2.21', EXE_FILES => [glob('script/*'), glob('bin/*')], CONFIGURE_REQUIRES => { "ExtUtils::MakeMaker" => "6.64" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-TCP-2.20/lib/Net/EmptyPort.pm new/Test-TCP-2.21/lib/Net/EmptyPort.pm --- old/Test-TCP-2.20/lib/Net/EmptyPort.pm 2019-08-04 00:48:29.000000000 +0200 +++ new/Test-TCP-2.21/lib/Net/EmptyPort.pm 2019-10-03 05:15:51.000000000 +0200 @@ -2,6 +2,8 @@ use strict; use warnings; use base qw/Exporter/; +use Errno qw/ECONNREFUSED/; +use Fcntl; use IO::Socket::IP; use Time::HiRes (); @@ -68,25 +70,17 @@ my ($host, $port, $proto) = @_ && ref $_[0] eq 'HASH' ? ($_[0]->{host}, $_[0]->{port}, $_[0]->{proto}) : (undef, @_); $host = '127.0.0.1' unless defined $host; - $proto = $proto ? lc($proto) : 'tcp'; - # for TCP, we do a remote port check - # for UDP, we do a local port check, like empty_port does - my $sock = ($proto eq 'tcp') ? - IO::Socket::IP->new( - Proto => 'tcp', - PeerAddr => $host, - PeerPort => $port, - V6Only => 1, - ) : - IO::Socket::IP->new( - Proto => $proto, - LocalAddr => $host, - LocalPort => $port, - V6Only => 1, - (($^O eq 'MSWin32') ? () : (ReuseAddr => 1)), - ) - ; + return _check_port_udp($host, $port) + if $proto && lc($proto) eq 'udp'; + + # TCP, check if possible to connect + my $sock = IO::Socket::IP->new( + Proto => 'tcp', + PeerAddr => $host, + PeerPort => $port, + V6Only => 1, + ); if ($sock) { close $sock; @@ -98,6 +92,34 @@ } +sub _check_port_udp { + my ($host, $port) = @_; + + # send some UDP data and see if ICMP error is being sent back (i.e. ECONNREFUSED) + my $sock = IO::Socket::IP->new( + Proto => 'udp', + PeerAddr => $host, + PeerPort => $port, + V6Only => 1, + ) or die "failed to create bound UDP socket:$!"; + fcntl($sock, F_SETFL, O_NONBLOCK) + or die "failed to set socket to nonblocking mode:$!"; + + $sock->send("0", 0) + or die "failed to send a UDP packet:$!"; + + my ($rfds, $efds) = ('', ''); + vec($rfds, fileno($sock), 1) = 1; + vec($efds, fileno($sock), 1) = 1; + select $rfds, undef, $efds, 0.1; + + # after 0.1 second of silence, we assume that the server is up + my $up = defined($sock->recv(my $data, 1000)) || $! != ECONNREFUSED; + close $sock; + $up; +} + + sub _make_waiter { my $max_wait = shift; my $waited = 0; @@ -246,6 +268,8 @@ The function recognizes the following keys when given a hashref as the argument. +When UDP is specified as the protocol, the `check_port` function sends a probe UDP packet to the designated port to see if an ICMP error message is returned, which indicates that the port is unassigned. The port is assumed to be assigned, unless such response is observed within 0.1 seconds. + =over 4 =item C<< host >> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-TCP-2.20/lib/Test/TCP.pm new/Test-TCP-2.21/lib/Test/TCP.pm --- old/Test-TCP-2.20/lib/Test/TCP.pm 2019-08-04 00:48:29.000000000 +0200 +++ new/Test-TCP-2.21/lib/Test/TCP.pm 2019-10-03 05:15:51.000000000 +0200 @@ -2,7 +2,7 @@ use strict; use warnings; use 5.00800; -our $VERSION = '2.20'; +our $VERSION = '2.21'; use base qw/Exporter/; use Test::SharedFork 0.12; use Test::More (); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-TCP-2.20/t/11_net_empty_port.t new/Test-TCP-2.21/t/11_net_empty_port.t --- old/Test-TCP-2.20/t/11_net_empty_port.t 2019-08-04 00:48:29.000000000 +0200 +++ new/Test-TCP-2.21/t/11_net_empty_port.t 2019-10-03 05:15:51.000000000 +0200 @@ -83,4 +83,15 @@ like ($@, qr/Expected .PeerService./, 'No args to check_port is fatal'); ok (!check_port (empty_port(), 'tcp'), '2 args to check_port'); +subtest 'udp-wait-port' => sub { + my $port = empty_port({proto => 'udp'}); + ok !check_port($port, 'udp'), "port is down"; + my $sock = IO::Socket::IP->new( + Proto => 'udp', + LocalPort => $port, + V6Only => 1, + ) or die "failed to bind to a UDP socket:$!"; + ok check_port($port, 'udp'), "port is up"; +}; + done_testing;