Fix msleep() if time goes backwards. Fixes bug 9789.
authorWayne Davison <wayned@samba.org>
Sun, 19 May 2013 22:52:00 +0000 (22:52 +0000)
committerWayne Davison <wayned@samba.org>
Sun, 19 May 2013 22:55:08 +0000 (22:55 +0000)
util.c

diff --git a/util.c b/util.c
index af0250cfb83c9c7c8dae12c65cb97879f439009b..0799dff561554462043fe319c5405396a90cb2e5 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1320,6 +1320,8 @@ 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;
        }