From owner-svn-src-all@FreeBSD.ORG Wed Nov 13 17:10:19 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2B0F2305; Wed, 13 Nov 2013 17:10:19 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1A10C2023; Wed, 13 Nov 2013 17:10:19 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rADHAI5X014816; Wed, 13 Nov 2013 17:10:18 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rADHAI3Q014815; Wed, 13 Nov 2013 17:10:18 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201311131710.rADHAI3Q014815@svn.freebsd.org> From: John Baldwin Date: Wed, 13 Nov 2013 17:10:18 +0000 (UTC) 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 X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Nov 2013 17:10:19 -0000 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: