diff options
-rw-r--r-- | source3/configure.in | 1 | ||||
-rw-r--r-- | source3/lib/util.c | 15 |
2 files changed, 15 insertions, 1 deletions
diff --git a/source3/configure.in b/source3/configure.in index 3530015110..9c3ee513af 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -1005,6 +1005,7 @@ AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf) AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink) AC_CHECK_FUNCS(syslog vsyslog timegm) AC_CHECK_FUNCS(setlocale nl_langinfo) +AC_CHECK_FUNCS(nanosleep) # setbuffer, shmget, shm_open are needed for smbtorture AC_CHECK_FUNCS(setbuffer shmget shm_open backtrace_symbols) AC_CHECK_HEADERS(libexc.h) diff --git a/source3/lib/util.c b/source3/lib/util.c index 4d66ed9655..455f87aaab 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -779,12 +779,24 @@ SMB_OFF_T transfer_file(int infd,int outfd,SMB_OFF_T n) void smb_msleep(unsigned int t) { +#if defined(HAVE_NANOSLEEP) + struct timespec tval; + int ret; + + tval.tv_sec = t/1000; + tval.tv_nsec = 1000000*(t%1000); + + do { + errno = 0; + ret = nanosleep(&tval, &tval); + } while (ret < 0 && errno == EINTR && (tval.tv_sec > 0 || tval.tv_nsec > 0)); +#else unsigned int tdiff=0; struct timeval tval,t1,t2; fd_set fds; GetTimeOfDay(&t1); - GetTimeOfDay(&t2); + t2 = t1; while (tdiff < t) { tval.tv_sec = (t-tdiff)/1000; @@ -808,6 +820,7 @@ void smb_msleep(unsigned int t) tdiff = TvalDiff(&t1,&t2); } +#endif } /**************************************************************************** |