svn commit: samba r4581 - in branches/SAMBA_3_0/source: . lib

jra at samba.org jra at samba.org
Thu Jan 6 23:45:54 GMT 2005


Author: jra
Date: 2005-01-06 23:45:53 +0000 (Thu, 06 Jan 2005)
New Revision: 4581

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4581

Log:
>From Derrell.Lipman at UnwiredUniverse.com. Use nanosleep instead of select
when we have it in smb_msleep.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/configure.in
   branches/SAMBA_3_0/source/lib/util.c


Changeset:
Modified: branches/SAMBA_3_0/source/configure.in
===================================================================
--- branches/SAMBA_3_0/source/configure.in	2005-01-06 23:45:44 UTC (rev 4580)
+++ branches/SAMBA_3_0/source/configure.in	2005-01-06 23:45:53 UTC (rev 4581)
@@ -1005,6 +1005,7 @@
 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)

Modified: branches/SAMBA_3_0/source/lib/util.c
===================================================================
--- branches/SAMBA_3_0/source/lib/util.c	2005-01-06 23:45:44 UTC (rev 4580)
+++ branches/SAMBA_3_0/source/lib/util.c	2005-01-06 23:45:53 UTC (rev 4581)
@@ -779,12 +779,24 @@
 
 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 @@
 
 		tdiff = TvalDiff(&t1,&t2);
 	}
+#endif
 }
 
 /****************************************************************************



More information about the samba-cvs mailing list