From owner-svn-src-head@FreeBSD.ORG Sun Sep 1 23:34:54 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 8571BCF4; Sun, 1 Sep 2013 23:34:54 +0000 (UTC) (envelope-from davide@FreeBSD.org) 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 726A22D6F; Sun, 1 Sep 2013 23:34:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r81NYsx4073911; Sun, 1 Sep 2013 23:34:54 GMT (envelope-from davide@svn.freebsd.org) Received: (from davide@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r81NYrkj073907; Sun, 1 Sep 2013 23:34:53 GMT (envelope-from davide@svn.freebsd.org) Message-Id: <201309012334.r81NYrkj073907@svn.freebsd.org> From: Davide Italiano Date: Sun, 1 Sep 2013 23:34:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r255138 - in head/sys: kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Sep 2013 23:34:54 -0000 Author: davide Date: Sun Sep 1 23:34:53 2013 New Revision: 255138 URL: http://svnweb.freebsd.org/changeset/base/255138 Log: Fix socket buffer timeouts precision using the new sbintime_t KPI instead of relying on the tvtohz() workaround. The latter has been introduced lately by jhb@ (r254699) in order to have a fix that can be backported to STABLE. Reported by: Vitja Makarov Reviewed by: jhb (earlier version) Modified: head/sys/kern/uipc_debug.c head/sys/kern/uipc_sockbuf.c head/sys/kern/uipc_socket.c head/sys/sys/sockbuf.h Modified: head/sys/kern/uipc_debug.c ============================================================================== --- head/sys/kern/uipc_debug.c Sun Sep 1 23:06:28 2013 (r255137) +++ head/sys/kern/uipc_debug.c Sun Sep 1 23:34:53 2013 (r255138) @@ -411,7 +411,7 @@ db_print_sockbuf(struct sockbuf *sb, con db_print_indent(indent); db_printf("sb_ctl: %u ", sb->sb_ctl); db_printf("sb_lowat: %d ", sb->sb_lowat); - db_printf("sb_timeo: %d\n", sb->sb_timeo); + db_printf("sb_timeo: %jd\n", sb->sb_timeo); db_print_indent(indent); db_printf("sb_flags: 0x%x (", sb->sb_flags); Modified: head/sys/kern/uipc_sockbuf.c ============================================================================== --- head/sys/kern/uipc_sockbuf.c Sun Sep 1 23:06:28 2013 (r255137) +++ head/sys/kern/uipc_sockbuf.c Sun Sep 1 23:34:53 2013 (r255138) @@ -127,9 +127,9 @@ sbwait(struct sockbuf *sb) SOCKBUF_LOCK_ASSERT(sb); sb->sb_flags |= SB_WAIT; - return (msleep(&sb->sb_cc, &sb->sb_mtx, + return (msleep_sbt(&sb->sb_cc, &sb->sb_mtx, (sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK | PCATCH, "sbwait", - sb->sb_timeo)); + sb->sb_timeo, 0, 0)); } int Modified: head/sys/kern/uipc_socket.c ============================================================================== --- head/sys/kern/uipc_socket.c Sun Sep 1 23:06:28 2013 (r255137) +++ head/sys/kern/uipc_socket.c Sun Sep 1 23:34:53 2013 (r255138) @@ -2541,7 +2541,7 @@ sosetopt(struct socket *so, struct socko int error, optval; struct linger l; struct timeval tv; - u_long val; + sbintime_t val; uint32_t val32; #ifdef MAC struct mac extmac; @@ -2703,7 +2703,7 @@ sosetopt(struct socket *so, struct socko error = EDOM; goto bad; } - val = tvtohz(&tv); + val = tvtosbt(tv); switch (sopt->sopt_name) { case SO_SNDTIMEO: @@ -2857,8 +2857,7 @@ integer: optval = (sopt->sopt_name == SO_SNDTIMEO ? so->so_snd.sb_timeo : so->so_rcv.sb_timeo); - tv.tv_sec = optval / hz; - tv.tv_usec = (optval % hz) * tick; + tv = sbttotv(optval); #ifdef COMPAT_FREEBSD32 if (SV_CURPROC_FLAG(SV_ILP32)) { struct timeval32 tv32; Modified: head/sys/sys/sockbuf.h ============================================================================== --- head/sys/sys/sockbuf.h Sun Sep 1 23:06:28 2013 (r255137) +++ head/sys/sys/sockbuf.h Sun Sep 1 23:34:53 2013 (r255138) @@ -97,7 +97,7 @@ struct sockbuf { u_int sb_mbmax; /* (c/d) max chars of mbufs to use */ u_int sb_ctl; /* (c/d) non-data chars in buffer */ int sb_lowat; /* (c/d) low water mark */ - int sb_timeo; /* (c/d) timeout for read/write */ + sbintime_t sb_timeo; /* (c/d) timeout for read/write */ short sb_flags; /* (c/d) flags, see below */ int (*sb_upcall)(struct socket *, void *, int); /* (c/d) */ void *sb_upcallarg; /* (c/d) */