[perl-Server-Starter] Fix a race between t/06-autorestart.t and t/05-killolddelay-echod.pl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



commit 451ab85b9f12cdc40c3bcf569b10771535c6206f
Author: Petr Písař <ppisar@xxxxxxxxxx>
Date:   Tue Sep 9 09:17:13 2014 +0200

    Fix a race between t/06-autorestart.t and t/05-killolddelay-echod.pl

 ...17-Synchronize-to-content-in-signame-file.patch |   78 ++++++++++++++++++++
 perl-Server-Starter.spec                           |   11 +++-
 2 files changed, 88 insertions(+), 1 deletions(-)
---
diff --git a/Server-Starter-0.17-Synchronize-to-content-in-signame-file.patch b/Server-Starter-0.17-Synchronize-to-content-in-signame-file.patch
new file mode 100644
index 0000000..6236bea
--- /dev/null
+++ b/Server-Starter-0.17-Synchronize-to-content-in-signame-file.patch
@@ -0,0 +1,78 @@
+From 3ec63d1650f9199d6d2b2413c7e855bc108646a4 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@xxxxxxxxxx>
+Date: Mon, 8 Sep 2014 19:03:08 +0200
+Subject: [PATCH] Synchronize to content in signame file
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+There is a race between t/06-autorestart.t and
+t/05-killolddelay-echod.pl. If t/05-killolddelay-echod.pl is not fast
+enough with writing received signal name (e.g. by adding "sleep 2;" in
+the beginning of a signal handler), the t/06-autorestart.t will get
+empty signame file and the test for the signal name will fail.
+
+This patch adds synchornization by locking the signame file.
+
+Similar to CPAN RT#73711.
+
+Signed-off-by: Petr Písař <ppisar@xxxxxxxxxx>
+---
+ t/05-killolddelay-echod.pl | 3 +++
+ t/06-autorestart.t         | 8 ++++++--
+ 2 files changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/t/05-killolddelay-echod.pl b/t/05-killolddelay-echod.pl
+index 5b48ca5..bd6be30 100755
+--- a/t/05-killolddelay-echod.pl
++++ b/t/05-killolddelay-echod.pl
+@@ -5,16 +5,19 @@ use warnings;
+ 
+ use lib qw(blib/lib lib);
+ 
++use Fcntl qw(:flock);
+ use IO::Socket::INET;
+ use Server::Starter qw(server_ports);
+ 
+ my $sigfn = shift @ARGV;
+ open my $sigfh, '>', $sigfn
+     or die "could not open file:$sigfn:$!";
++flock $sigfh, LOCK_EX or die "could lock file:$sigfh:$!";
+ 
+ $SIG{TERM} = $SIG{USR1} = sub {
+     my $signame = shift;
+     print $sigfh $signame;
++    flock $sigfh, LOCK_UN or die $!;
+     sleep 1;
+     exit 0;
+ };
+diff --git a/t/06-autorestart.t b/t/06-autorestart.t
+index 9401500..58e98d1 100644
+--- a/t/06-autorestart.t
++++ b/t/06-autorestart.t
+@@ -1,6 +1,7 @@
+ use strict;
+ use warnings;
+ 
++use Fcntl qw(:flock);
+ use File::Temp ();
+ use Test::TCP;
+ use Test::More tests => 26;
+@@ -61,9 +62,12 @@ for my $signal_on_hup ('TERM', 'USR1') {
+                 'status after auto-restart');
+             is(
+                 do {
+-                    open my $fh, '<', "$tempdir/signame"
++                    open my $fh, '+<', "$tempdir/signame"
+                         or die $!;
+-                    <$fh>;
++                    flock $fh, LOCK_EX or die $!;
++                    my $signal = <$fh>;
++                    flock $fh, LOCK_UN or die $!;
++                    $signal;
+                 },
+                 $signal_on_hup,
+                 'signal sent on hup',
+-- 
+1.9.3
+
diff --git a/perl-Server-Starter.spec b/perl-Server-Starter.spec
index dd3fc01..3250263 100644
--- a/perl-Server-Starter.spec
+++ b/perl-Server-Starter.spec
@@ -1,6 +1,6 @@
 Name:           perl-Server-Starter
 Version:        0.17
-Release:        7%{?dist}
+Release:        8%{?dist}
 Summary:        Superdaemon for hot-deploying server programs
 License:        GPL+ or Artistic
 Group:          Development/Libraries
@@ -16,6 +16,9 @@ Patch2:         Server-Starter-0.17-Synchronize-to-PID-in-t-06-autorestart.t.pat
 Patch3:         Server-Starter-0.17-Synchronize-to-PID-in-t-01-starter.t.patch
 # Fix t/05-killolddelay.t race, bug #1100158, CPAN RT#73711
 Patch4:         Server-Starter-0.17-Synchronize-to-PID-in-t-05-killolddelay.t.patch
+# Fix a race between t/06-autorestart.t and t/05-killolddelay-echod.pl,
+# bug #1100158, CPAN RT#73711
+Patch5:         Server-Starter-0.17-Synchronize-to-content-in-signame-file.patch
 BuildArch:      noarch
 
 BuildRequires:  perl(ExtUtils::MakeMaker) >= 6.42
@@ -24,6 +27,7 @@ BuildRequires:  perl(List::MoreUtils)
 BuildRequires:  perl(Proc::Wait3)
 BuildRequires:  perl(Scope::Guard)
 # For the tests
+BuildRequires:  perl(Fcntl)
 BuildRequires:  perl(Test::TCP) >= 2.00
 
 Requires:       perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
@@ -54,6 +58,7 @@ perl-Server-Starter's start_server script.
 %patch2 -p1
 %patch3 -p1
 %patch4 -p1
+%patch5 -p1
 
 %build
 # --skipdeps causes ExtUtils::AutoInstall not to try auto-installing
@@ -84,6 +89,10 @@ make test
 %{_mandir}/man1/start_server.*
 
 %changelog
+* Tue Sep 09 2014 Petr Pisar <ppisar@xxxxxxxxxx> - 0.17-8
+- Fix a race between t/06-autorestart.t and t/05-killolddelay-echod.pl
+  (bug #1100158)
+
 * Fri Aug 29 2014 Jitka Plesnikova <jplesnik@xxxxxxxxxx> - 0.17-7
 - Perl 5.20 rebuild
 
--
Fedora Extras Perl SIG
http://www.fedoraproject.org/wiki/Extras/SIGs/Perl
perl-devel mailing list
perl-devel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/perl-devel





[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Legacy Announce]     [Fedora PHP Devel]     [Kernel Devel]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Big List of Linux Books]     [Gimp]     [Yosemite Information]
  Powered by Linux