MCPcopy Index your code
hub / github.com/RsyncProject/rsync / msleep

Function msleep

util2.c:36–71  ·  view source on GitHub ↗

* Sleep for a specified number of milliseconds. * * Always returns True. **/

Source from the content-addressed store, hash-verified

34 * Always returns True.
35 **/
36int msleep(int t)
37{
38#ifdef HAVE_NANOSLEEP
39 struct timespec ts;
40
41 ts.tv_sec = t / 1000;
42 ts.tv_nsec = (t % 1000) * 1000000L;
43
44 while (nanosleep(&ts, &ts) < 0 && errno == EINTR) {}
45
46#elif defined HAVE_USLEEP
47 usleep(t*1000);
48
49#else
50 int tdiff = 0;
51 struct timeval tval, t1, t2;
52
53 gettimeofday(&t1, NULL);
54
55 while (tdiff < t) {
56 tval.tv_sec = (t-tdiff)/1000;
57 tval.tv_usec = 1000*((t-tdiff)%1000);
58
59 errno = 0;
60 select(0,NULL,NULL, NULL, &tval);
61
62 gettimeofday(&t2, NULL);
63 tdiff = (t2.tv_sec - t1.tv_sec)*1000 +
64 (t2.tv_usec - t1.tv_usec)/1000;
65 if (tdiff < 0)
66 t1 = t2; /* Time went backwards, so start over. */
67 }
68#endif
69
70 return True;
71}
72
73void *my_alloc(void *ptr, size_t num, size_t size, const char *file, int line)
74{

Callers 7

option_errorFunction · 0.85
_exit_cleanupFunction · 0.85
whine_about_eofFunction · 0.85
sig_intFunction · 0.85
wait_process_with_flushFunction · 0.85
do_recvFunction · 0.85
rsync_moduleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected