From owner-freebsd-hackers@FreeBSD.ORG Sun Jul 31 16:19:45 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 32AE3106566B for ; Sun, 31 Jul 2011 16:19:45 +0000 (UTC) (envelope-from kuku@kukulies.org) Received: from kukulies.org (mail.kukulies.org [78.47.239.221]) by mx1.freebsd.org (Postfix) with ESMTP id EA4BA8FC12 for ; Sun, 31 Jul 2011 16:19:44 +0000 (UTC) Received: by kukulies.org (Postfix, from userid 5001) id 3B5FB1AC003; Sun, 31 Jul 2011 18:19:44 +0200 (CEST) Received: from [192.168.2.102] (p4FD5EB53.dip.t-dialin.net [79.213.235.83]) by kukulies.org (Postfix) with ESMTPSA id 0F7271AC002; Sun, 31 Jul 2011 18:19:41 +0200 (CEST) Message-ID: <4E358095.9040606@kukulies.org> Date: Sun, 31 Jul 2011 18:19:33 +0200 From: "Christoph P.U. Kukulies" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: Jilles Tjoelker References: <4E356498.40001@kukulies.org> <20110731154511.GB66652@stack.nl> In-Reply-To: <20110731154511.GB66652@stack.nl> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org Subject: Re: invalid argument in select() when peer socket is in FD_SET X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Jul 2011 16:19:45 -0000 Am 31.07.2011 17:45, schrieb Jilles Tjoelker: > On Sun, Jul 31, 2011 at 04:20:08PM +0200, Christoph P.U. Kukulies wrote: >> I posted this on freebsd-questions also but maybe the expert density >> isn't that high as here in "hackers". >> Since I think it may be a design or implementation issue in FreeBSDs' >> select(), I'm posting it here as well, >> hoping to get an experts' answer. >> I have written a small server to test TCP/IP roundtrip times of the >> packets in a proprietary protocol and while >> compiling and running this server on different platforms (Windows >> 7/cygwin, UbuntuLinux, FreeBSD 8.0 Release), I found >> that the server produces an error when the listening socket (on which >> the accept() is performed) is also >> member of the select() fd_set. >> On the other platforms the program works without error, just under >> FreeBSD I'm getting this "invalid argument" error. >> Comments appreciated (despite comments about the error checking logic >> [snip] >> tv.tv_sec = 0; >> tv.tv_usec = 5000000; /* 5 seconds */ >> [snip] >> n = select(nfds,&readfds, >> (fd_set *) NULL, /* not interested in write */ >> (fd_set *) NULL, /* ...or exceptions */ >> &tv); /* timeout */ > The number of microseconds in a struct timeval must be nonnegative and > less than one million (likewise, the number of nanoseconds in a struct > timespec must be nonnegative and less than 1000 million). > > FreeBSD checks this strictly in most functions. Ah, thanks. That's another plus for FreeBSD. Somehow I have been mislead during the development of the sample server that it escaped to me, that the timestruct was the culprit. Thanks again. saved me a lot of headaches. -- Christoph