bug in job_process_catch_runaway when clock moves backward?

upstart at eehouse.org upstart at eehouse.org
Thu Mar 26 18:34:14 GMT 2009


On Thu, Mar 26, 2009 at 02:23:28PM -0400, Casey Dahlin wrote:
> upstart at eehouse.org wrote:
> > I've run into a what looks like a bug in job_process_catch_runaway().
> > It occurs when the wall clock moves backwards.  If a job has been
> > spawned initially at some time, and the clock then moves backwards N
> > minutes, then in effect the respawn_interval is increased by N
> > minutes.  If the process has to be respawned up to respawn_limit times
> > within that longer interval, it will never be respawned again (until
> > reboot.)
> > 
> > One fix is to test for a negative interval:
> > 
> > 		interval = time (NULL) - job->respawn_time;
> > 		if (interval >= 0 && interval < job->class->respawn_interval) {
> > 
> > Another would be to use clock_gettime() with CLOCK_MONOTONIC instead
> > of time(NULL).
> > 
> > Thoughts?  If this is a bug, I'm happy to submit a patch.  I prefer
> > the CLOCK_MONOTONIC fix myself.
> > 
> > Thanks,
> > 
> > --Eric
> 
> I'd second that the CLOCK_MONOTONIC fix is right for this case. While we're here we should probably screen for any other time related issues like this that might come up.
> 
> Also, you neglected to mention what version you found this in :)

We're using 0.3.8 (build system issues), but it's in 0.5.1 too.

--Eric
-- 
******************************************************************************
* From the desktop of: Eric House, xwords at eehouse.org                        *
*       Crosswords 4.2 for MS Smartphone and PocketPC is OUT: xwords.sf.net  *
******************************************************************************



More information about the upstart-devel mailing list