Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Jul 2006 11:39:34 GMT
From:      Roman Divacky <rdivacky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 102135 for review
Message-ID:  <200607221139.k6MBdYOX029421@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=102135

Change 102135 by rdivacky@rdivacky_witten on 2006/07/22 11:39:07

	Fix the timeout_hz counting.

Affected files ...

.. //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_futex.c#6 edit

Differences ...

==== //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_futex.c#6 (text+ko) ====

@@ -117,9 +117,24 @@
 		    		td->td_proc->p_pid, args->val, 
 		    		args->uaddr, val, timeout.tv_sec, timeout.tv_nsec); 
 #endif
-		tv.tv_usec = timeout.tv_sec * 1000 + timeout.tv_nsec / 1000000;
+		tv.tv_usec = timeout.tv_sec * 1000000 + timeout.tv_nsec / 1000;
 		timeout_hz = tvtohz(&tv);
 
+		if (timeout.tv_sec == 0 && timeout.tv_nsec == 0)
+		   	timeout_hz = 0;
+      		/*
+                 * If the user process requests a non null timeout,
+                 * make sure we do not turn it into an infinite
+                 * timeout because timeout_hz gets null.
+                 *
+                 * We use a minimal timeout of 1/hz. Mayve it would
+                 * make sense to just return ETIMEDOUT without sleeping.
+                 */
+                if (((timeout.tv_sec != 0) || (timeout.tv_nsec != 0)) &&
+                    (timeout_hz == 0))
+                        timeout_hz = 1;
+
+
 		f = futex_get(args->uaddr);
 		ret = futex_sleep(f, td, timeout_hz);
 		futex_put(f);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607221139.k6MBdYOX029421>