Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 308931

Summary: net-misc/stunnel pid-file creation too slow; init file claims failure
Product: Gentoo Linux Reporter: Preston Crow <pc-gentoo-bugs08a>
Component: New packagesAssignee: Lance Albertson (RETIRED) <ramereth>
Status: RESOLVED FIXED    
Severity: normal CC: disp.reg.bugs.gentoo
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Preston Crow 2010-03-11 04:47:43 UTC
When running:
  /etc/init.d/stunnel start
It complains:
stunnel         | * Starting stunnel ...
stunnel         | *    error starting: /etc/stunnel/stunnel.conf          [ !! ]

The process is created, and it works correctly.  Digging into the init script I find that the error indicates that it can't find the pid file as specified in the configuration file.  Checking in the file system, I see that it was created.  Apparently stunnel will fork into the background before creating the pid file, so there's a race condition that on my system is causing it to consistently fail that check.  If I add another display message after starting the daemon but before checking for the pid file, the script reports success.

While the correct fix is to push this upstream to eliminate the race condition in the creation of the pid file, a workaround is to update the check for the pid file to first sleep a half-second if the file isn't there.  This change makes it work for me:

            elif ${DAEMON} ${ARGS} ; then
                if ! test -f ${CHROOT}/${PIDFILE} ; then
		    sleep 0.5s # give the daemon time to create the pid file
		fi
                if test -f ${CHROOT}/${PIDFILE} ; then
                    einfo "   ${file}"
                else
                    eerror "   error starting: ${file}"
                fi
            fi
Comment 1 Lance Albertson (RETIRED) gentoo-dev 2010-06-21 00:48:22 UTC
Thanks for reporting the bug. I had noticed that problem as well but didn't get a chance to look into it further. While this fix is kind of a workaround I think its the most simple approach to it.

I just committed your fix to portage.