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

Bug#41046: Possible fix

Maybe ud should check /proc/uptime to see what the real uptime is. That guards against ud being killed/restarted/whatever, but it has another flaw: on 32-bit machines /proc/uptime rewinds every 49.7 days (on 2.6, 497 days on 2.4). A better scheme would be to log the /proc/uptime value and the amount of rewinds detected to a /var/tmp file. Whenever /proc/uptime reports a lower value than our last logged one, we've found ourselves a rewind. A schematical overview of this process would be like this:
1. Read /proc/uptime
2. Compare the uptime value with the previous one. If it's lower, increase the rewind counter.
3. Overwrite the old uptime value and rewind count with the new ones
4. Calculate uptime and write it to the records
5. Sleep for some time
6. Return to 1
Uptime (in seconds) can be calculated the usual way, adding in rewinds*49.7 days.

The only case in which this doesn't work is when ud isn't there to watch /proc/uptime for 49.7 days straight, but most admins know better than to leave their system in single-user mode for 50 days. Of course the /var/tmp file should be nuked on reboot, but I believe FHS dictates that /var/tmp be cleaned at boot time.

Reply to: