1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-29 13:49:30 +03:00

r4581: From Derrell.Lipman@UnwiredUniverse.com. Use nanosleep instead of select

when we have it in smb_msleep.
Jeremy.
This commit is contained in:
Jeremy Allison
2005-01-06 23:45:53 +00:00
committed by Gerald (Jerry) Carter
parent 9ade9bf49c
commit 465c207ffb
2 changed files with 15 additions and 1 deletions

View File

@ -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)

View File

@ -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
}
/****************************************************************************