]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Use usleep() for msleep() if it is available.
authorWayne Davison <wayned@samba.org>
Thu, 27 Nov 2014 19:57:35 +0000 (11:57 -0800)
committerWayne Davison <wayned@samba.org>
Thu, 27 Nov 2014 20:02:56 +0000 (12:02 -0800)
NEWS
configure.ac
util2.c

diff --git a/NEWS b/NEWS
index 7bc205ddf6304866f7aaf39c0df203abbafb6d17..84df781db65659fc46f2928621cc05721366a582 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,7 +9,9 @@ Changes since 3.1.1:
   ENHANCEMENTS:
 
     - Added "(DRY RUN)" info to the --debug=exit output line.
-    - Added a few extra long options to rrsync script, which will make BackupPC happier.
+    - Use usleep() for our msleep() function if it is available.
+    - Added a few extra long-option names to rrsync script, which will make
+      BackupPC happier.
 
   DEVELOPER RELATED:
 
index 70381f70ee0fa57f3f09d6c1c98edfe3c2f5bf2a..5c557a897298b71f0d1fb3b2d1a9c373db231347 100644 (file)
@@ -602,7 +602,7 @@ AC_CHECK_FUNCS(waitpid wait4 getcwd strdup chown chmod lchmod mknod mkfifo \
     setlocale setmode open64 lseek64 mkstemp64 mtrace va_copy __va_copy \
     seteuid strerror putenv iconv_open locale_charset nl_langinfo getxattr \
     extattr_get_link sigaction sigprocmask setattrlist getgrouplist \
-    initgroups utimensat posix_fallocate attropen setvbuf)
+    initgroups utimensat posix_fallocate attropen setvbuf usleep)
 
 dnl cygwin iconv.h defines iconv_open as libiconv_open
 if test x"$ac_cv_func_iconv_open" != x"yes"; then
diff --git a/util2.c b/util2.c
index 6ffbcec6325d26a802f7ffe2d691f32d4413e116..bc9f66a44063f173905ffe42cd927557afd1e2ea 100644 (file)
--- a/util2.c
+++ b/util2.c
@@ -35,6 +35,9 @@ extern int checksum_len;
  **/
 int msleep(int t)
 {
+#ifdef HAVE_USLEEP
+       usleep(t*1000);
+#else
        int tdiff = 0;
        struct timeval tval, t1, t2;
 
@@ -48,11 +51,12 @@ int msleep(int t)
                select(0,NULL,NULL, NULL, &tval);
 
                gettimeofday(&t2, NULL);
-               if (t2.tv_sec < t1.tv_sec)
-                       t1 = t2; /* Time went backwards, so start over. */
                tdiff = (t2.tv_sec - t1.tv_sec)*1000 +
                        (t2.tv_usec - t1.tv_usec)/1000;
+               if (tdiff < 0)
+                       t1 = t2; /* Time went backwards, so start over. */
        }
+#endif
 
        return True;
 }