Bug 9789 - rsync hangs when NTP update system clock time
Summary: rsync hangs when NTP update system clock time
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 2.6.2
Hardware: PPC Linux
: P5 normal (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
Depends on:
Reported: 2013-04-12 15:16 UTC by Abhinav
Modified: 2013-05-19 22:55 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Abhinav 2013-04-12 15:16:06 UTC

There is a periodic rsync which runs in my system every 1 min. When system is coming up, NTP update the time and if at the same moment this periodic rsync executes, then it gets hanged. Following was the output after running strace on rsync:

After going through the code of rsync it looks like there is problem in msleep function. It uses gettimeofday linux API. If system clock time changes between two successive calls to this function then the time difference will be a very large value which is getting assigned to a 32bit signed integer variable tdiff. Since that time difference is larger than 2^31, tdiff finally gets a large negative number.
this number is passed as positive value in the select call used for sleeping.
Thus ultimately leading to rsync hang for a very large amount of time.
In my case it hanged for 550hrs. I tried to assigned NTP time reset value in ms to a 32-bit signed int variable, and it is coming around 550hrs. 
I just wanted to know has this issue been fix in higher versions or not, and if fixed, then which version.

Many thanks in advance.
Comment 1 Abhinav 2013-04-17 12:02:22 UTC
Looks like nobody is taking care of this bugzilla
still got no response even after so many days of posting the comment
Too bad...
Comment 2 Wayne Davison 2013-05-19 22:55:05 UTC
I'm checking in a change to the msleep() function that will ensure that a backward movement in time doesn't generate a huge sleep.  These 2 new lines are being added after the call to gettimeofday(&t2, NULL):

+                if (t2.tv_sec < t1.tv_sec)
+                        t1 = t2; /* Time went backwards, so start over. */

This fix will be released in 3.1.0.