From owner-freebsd-hackers Sun Jul 14 7:57:13 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1E3B337B400 for ; Sun, 14 Jul 2002 07:57:09 -0700 (PDT) Received: from iguana.icir.org (iguana.icir.org [192.150.187.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id B0E6F43E65 for ; Sun, 14 Jul 2002 07:57:08 -0700 (PDT) (envelope-from rizzo@iguana.icir.org) Received: (from rizzo@localhost) by iguana.icir.org (8.11.6/8.11.3) id g6EEv6E75100; Sun, 14 Jul 2002 07:57:06 -0700 (PDT) (envelope-from rizzo) Date: Sun, 14 Jul 2002 07:57:06 -0700 From: Luigi Rizzo To: David Miller Cc: hackers@FreeBSD.ORG Subject: Re: setsockopt() weirdness Message-ID: <20020714075706.A74633@iguana.icir.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: ; from dmiller@sparks.net on Sun, Jul 14, 2002 at 10:49:56AM -0400 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, Jul 14, 2002 at 10:49:56AM -0400, David Miller wrote: > I'm probably doing something basic wrong, but I'm getting a very > inconsistent response when using setsockopt to set the SO_RCVTIMEO to > seven seconds or more. i would suspect some overflow of 16-bit fields used to store the timeout value (scaled by HZ) . What value of "HZ" are you using ? And what is the exact threshold where it fails (i'd bet it is between 6.5 and 6.6 sec.) ? cheers luigi > > The program included works on a 4.3R system, a 4.4R and a 4.6stable system > SUPd June 24. The systems are a 486, 800 MHz P-III, and 1.1 GHz t-bird > respectively. > > The program fails to work on a 1 GHz t-bird with 4.6S SUPd last night, and > an XP1700+ SUP'd several days ago. > > "Works" is defined as: > > bash-2.05$ ./x > Successfully set timeout to 6 > Successfully set timeout to 7 > > "Not works" is defined as: > > alex:c$ ./x > Successfully set timeout to 6 > Error 33 trying to set socket timeout to 7 > > > Clue greatly appreciated. > > --- David > > The program: > > #include > #include > #include > #include > #include > #include > #include > #include > > > extern int errno; > > main() { > > int sock, timeout ; > struct itimerval s_timeout; > > if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { > printf("Couldn't get a socket, err %d\n",sock); > exit(-1); > } > > s_timeout.it_interval.tv_usec = 0; > s_timeout.it_value.tv_usec = 0; > > s_timeout.it_value.tv_sec = 0; > s_timeout.it_interval.tv_sec = 6; > > if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, > &s_timeout, sizeof(s_timeout))) { > printf("Error %d trying to set socket timeout\n",errno); > } > else { > printf("Successfully set timeout to %d\n", > s_timeout.it_interval.tv_sec); > } > > s_timeout.it_interval.tv_sec = 7; > > if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, > &s_timeout, sizeof(s_timeout))) { > printf("Error %d trying to set socket timeout to %d\n", > errno, s_timeout.it_interval.tv_sec); > } > else { > printf("Successfully set timeout to %d\n", > s_timeout.it_interval.tv_sec); > } > } > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message