Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Nov 2013 17:10:18 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r258100 - stable/8/sys/kern
Message-ID:  <201311131710.rADHAI3Q014815@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Wed Nov 13 17:10:18 2013
New Revision: 258100
URL: http://svnweb.freebsd.org/changeset/base/258100

Log:
  MFC 254699,255030:
  Use tvtohz() to convert a socket buffer timeout to a tick value rather
  than using a home-rolled version.  The home-rolled version could result
  in shorter-than-requested sleeps.
  
  PR:		kern/181416

Modified:
  stable/8/sys/kern/uipc_socket.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/kern/   (props changed)

Modified: stable/8/sys/kern/uipc_socket.c
==============================================================================
--- stable/8/sys/kern/uipc_socket.c	Wed Nov 13 17:08:37 2013	(r258099)
+++ stable/8/sys/kern/uipc_socket.c	Wed Nov 13 17:10:18 2013	(r258100)
@@ -2570,22 +2570,12 @@ sosetopt(struct socket *so, struct socko
 				    sizeof tv);
 			if (error)
 				goto bad;
-
-			/* assert(hz > 0); */
-			if (tv.tv_sec < 0 || tv.tv_sec > INT_MAX / hz ||
-			    tv.tv_usec < 0 || tv.tv_usec >= 1000000) {
-				error = EDOM;
-				goto bad;
-			}
-			/* assert(tick > 0); */
-			/* assert(ULONG_MAX - INT_MAX >= 1000000); */
-			val = (u_long)(tv.tv_sec * hz) + tv.tv_usec / tick;
-			if (val > INT_MAX) {
+			if (tv.tv_sec < 0 || tv.tv_usec < 0 ||
+			    tv.tv_usec >= 1000000) {
 				error = EDOM;
 				goto bad;
 			}
-			if (val == 0 && tv.tv_usec != 0)
-				val = 1;
+			val = tvtohz(&tv);
 
 			switch (sopt->sopt_name) {
 			case SO_SNDTIMEO:



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