summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2012-07-10 11:42:54 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2012-07-10 11:42:54 +0000
commit299487a62cc115bc8bca8214d0a4b3c35d983de4 (patch)
tree7231a3412b95c1e4c01b5cc4278fdcf06d0c7738 /sys
parenteeb061e6a00c9fe390c9aabd9f328893f1ed5811 (diff)
For setsockopt(SO_{SND,RCV}TIMEO), convert the timeval to ticks using
tvtohz() so that the rounding is correct and we don't time out a tick early ok claudio@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_socket.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 10b1fa202b0..c081068a59d 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket.c,v 1.102 2012/07/10 09:40:25 claudio Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.103 2012/07/10 11:42:53 guenther Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@@ -1482,20 +1482,18 @@ sosetopt(struct socket *so, int level, int optname, struct mbuf *m0)
case SO_RCVTIMEO:
{
struct timeval *tv;
- u_short val;
+ int val;
if (m == NULL || m->m_len < sizeof (*tv)) {
error = EINVAL;
goto bad;
}
tv = mtod(m, struct timeval *);
- if (tv->tv_sec > (USHRT_MAX - tv->tv_usec / tick) / hz) {
+ val = tvtohz(tv);
+ if (val > USHRT_MAX) {
error = EDOM;
goto bad;
}
- val = tv->tv_sec * hz + tv->tv_usec / tick;
- if (val == 0 && tv->tv_usec != 0)
- val = 1;
switch (optname) {