Date: Tue, 3 Sep 2002 07:37:17 +0400 (MSD) From: "vfom" <vfom@narod.ru> To: FreeBSD-gnats-submit@FreeBSD.org Subject: kern/42352: Impossible to set RCV timeout on a socket to 33 sec, with "option HZ=1000" in ke Message-ID: <3D742E6D.00000A.02440@soapbox.yandex.ru>
next in thread | raw e-mail | index | archive | help
>Number: 42352
>Category: kern
>Synopsis: Impossible to set RCV timeout on a socket to 33 sec, with "option HZ=1000" in kernel
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Sep 02 20:40:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Viktor Fomichev
>Release: FreeBSD 4.6.2-RELEASE i386
>Organization:
home-user
>Environment:
System: FreeBSD shark.office.sice.ru 4.6.2-RELEASE FreeBSD 4.6.2-RELEASE #0: Wed Aug 28 12:20:43 NOVST 2002 root@gog:/usr/src/sys/compile/GROM.ipsec.tap i386
>Description:
Impossible to set receive and send timeout on a socket to more then 33 secs.
when kernel compiled with "option HZ=1000"
It recomended for network device polling. (man 4 polling)
"Setsockopt" returns with error: Numerical argument out of domain.
>How-To-Repeat:
Compile new kernel with "option HZ=1000". Install new kernel and reboot.
Compile and run following program. Output looks like:
# ./test_sockopt
recv 32...
test_sockopt: recv: Resource temporarily unavailable
test_sockopt: setsockopt: Numerical argument out of domain
#
test_sockopt.c:
# include <sys/types.h>
# include <sys/socket.h>
# include <sys/time.h>
# include <stdio.h>
# include <errno.h>
# include <string.h>
# include <err.h>
# include <netinet/in.h>
int
main(int argc, char *argv[])
{
int s;
struct timeval tv;
struct sockaddr_in sin;
u_char buf[1000];
if ((s = socket(PF_INET, SOCK_DGRAM, 0)) == -1)
err(1, "socket");
sin.sin_len = sizeof(sin);
sin.sin_family = AF_INET;
sin.sin_port = htons(10000);
sin.sin_addr.s_addr = INADDR_ANY;
if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) == -1)
err(1, "bind");
tv.tv_sec = 32;
tv.tv_usec = 0;
if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1)
err(1, "setsockopt");
printf("recv 32...\n");
if (recv(s, buf, sizeof(buf), 0) == -1)
warn("recv");
tv.tv_sec = 33;
tv.tv_usec = 0;
if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1)
err(1, "setsockopt");
printf("recv 33...\n");
if (recv(s, buf, sizeof(buf), 0) == -1)
warn("recv");
return (0);
}
>Fix:
Not known.
It seems to me, we have to change "socket" structure definition
in "sys/socketvar.h", in substructure "sockbuf" - sb_timeo must be
at least 4 byte integer, or long - to forget the problem forever.
>Release-Note:
>Audit-Trail:
>Unformatted:
X-send-pr-version: 3.113
X-GNATS-Notify:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D742E6D.00000A.02440>
