[portreserve] Avoid a race during start-up if there are no configured ports (bug #901988).

Tim Waugh twaugh at fedoraproject.org
Wed Nov 27 09:54:30 UTC 2013


commit 7a721a0465d37937800015181fb7134a9ab48e2c
Author: Tim Waugh <twaugh at redhat.com>
Date:   Wed Nov 27 09:45:00 2013 +0000

    Avoid a race during start-up if there are no configured ports (bug #901988).
    
    Also:
    
    Moved tmpfiles configuration file to correct location.
    
    Don't use %ghost in manifest for state directory, in order to make
    sure it is ready to use after installation.
    
    Resolves: rhbz#901988

 portreserve-pid-file.patch |   13 +++++++++++++
 portreserve.spec           |   20 +++++++++++++++-----
 2 files changed, 28 insertions(+), 5 deletions(-)
---
diff --git a/portreserve-pid-file.patch b/portreserve-pid-file.patch
new file mode 100644
index 0000000..c865712
--- /dev/null
+++ b/portreserve-pid-file.patch
@@ -0,0 +1,13 @@
+diff -up portreserve-0.0.5/src/portreserve.c.pid-file portreserve-0.0.5/src/portreserve.c
+--- portreserve-0.0.5/src/portreserve.c.pid-file	2011-06-23 16:50:21.000000000 +0100
++++ portreserve-0.0.5/src/portreserve.c	2013-11-27 09:48:01.073647566 +0000
+@@ -314,6 +314,9 @@ portreserve (void)
+ 
+ 	free (cfgfile);
+ 
++	/* Give init a chance to spot our PID file (bug #901988). */
++	sleep (1);
++
+ 	return 0;
+ }
+ 
diff --git a/portreserve.spec b/portreserve.spec
index 5e7d296..4988401 100644
--- a/portreserve.spec
+++ b/portreserve.spec
@@ -1,12 +1,13 @@
 Summary: TCP port reservation utility
 Name: portreserve
 Version: 0.0.5
-Release: 8%{?dist}
+Release: 9%{?dist}
 License: GPLv2+
 Group: System Environment/Daemons
 URL: http://cyberelk.net/tim/portreserve/
 Source0: http://cyberelk.net/tim/data/portreserve/stable/%{name}-%{version}.tar.bz2
 Source1: portreserve.service
+Patch1: portreserve-pid-file.patch
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Requires(post): systemd-units
 Requires(preun): systemd-units
@@ -30,6 +31,9 @@ port (generally in the init script).
 %prep
 %setup -q
 
+# Avoid a race during start-up if there are no configured ports (bug #1034139).
+%patch1 -p1 -b .pid-file
+
 %build
 %configure --sbindir=/sbin
 make
@@ -41,8 +45,8 @@ mkdir -p %{buildroot}%{_localstatedir}/run/portreserve
 mkdir -p %{buildroot}%{_unitdir}
 install -m644 %{SOURCE1} %{buildroot}%{_unitdir}/portreserve.service
 mkdir -p %{buildroot}%{_sysconfdir}/portreserve
-mkdir -p %{buildroot}%{_sysconfdir}/tmpfiles.d
-cat <<EOF > %{buildroot}%{_sysconfdir}/tmpfiles.d/portreserve.conf
+mkdir -p %{buildroot}%{_tmpfilesdir}
+cat <<EOF > %{buildroot}%{_tmpfilesdir}/portreserve.conf
 d %{_localstatedir}/run/portreserve 0755 root root 10d
 EOF
 
@@ -71,14 +75,20 @@ rm -rf %{buildroot}
 %files
 %defattr(-,root,root)
 %doc ChangeLog README COPYING NEWS
-%ghost %dir %{_localstatedir}/run/portreserve
+%dir %{_localstatedir}/run/portreserve
 %dir %{_sysconfdir}/portreserve
-%config %{_sysconfdir}/tmpfiles.d/portreserve.conf
+%config %{_tmpfilesdir}/portreserve.conf
 %{_unitdir}/portreserve.service
 /sbin/*
 %{_mandir}/*/*
 
 %changelog
+* Tue Nov 26 2013 Tim Waugh <twaugh at redhat.com> - 0.0.5-9
+- Avoid a race during start-up if there are no configured ports (bug #901988).
+- Moved tmpfiles configuration file to correct location.
+- Don't use %ghost in manifest for state directory, in order to make
+  sure it is ready to use after installation.
+
 * Sun Aug 04 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.0.5-8
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
 


More information about the scm-commits mailing list