diff options
author | Jeremy Allison <jra@samba.org> | 2005-01-06 23:45:53 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:53:48 -0500 |
commit | c057e4591b30864ffeaa7155f58821fb5abeabea (patch) | |
tree | 7bb1c7f398f7a2a794e895a362856db8f8c5b860 | |
parent | be606e8eeb0a419189bd8f44975c80e182474993 (diff) | |
download | samba-c057e4591b30864ffeaa7155f58821fb5abeabea.tar.gz samba-c057e4591b30864ffeaa7155f58821fb5abeabea.tar.bz2 samba-c057e4591b30864ffeaa7155f58821fb5abeabea.zip |
r4581: From Derrell.Lipman@UnwiredUniverse.com. Use nanosleep instead of select
when we have it in smb_msleep.
Jeremy.
(This used to be commit 465c207ffbcd5ee859faee282ef220a6c72e4eeb)
-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 } /**************************************************************************** |