Author: jhb
Date: Wed Nov 13 17:08:37 2013
New Revision: 258099
URL: http://svnweb.freebsd.org/changeset/base/258099

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/9/sys/kern/uipc_socket.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/uipc_socket.c
==============================================================================
--- stable/9/sys/kern/uipc_socket.c     Wed Nov 13 17:06:26 2013        
(r258098)
+++ stable/9/sys/kern/uipc_socket.c     Wed Nov 13 17:08:37 2013        
(r258099)
@@ -2654,22 +2654,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:
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to