Date: Wed, 17 Dec 1997 09:30:02 -0800 (PST) From: Bruce Evans <bde@zeta.org.au> To: freebsd-bugs Subject: Re: bin/5306: gethostbyname() returns herror "Unknown host" on well known hosts Message-ID: <199712171730.JAA26387@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/5306; it has been noted by GNATS. From: Bruce Evans <bde@zeta.org.au> To: bde@zeta.org.au, chris@netmonger.net, freebsd-gnats-submit@freebsd.org, robert@superior.net Cc: Subject: Re: bin/5306: gethostbyname() returns herror "Unknown host" on well known hosts Date: Thu, 18 Dec 1997 04:23:38 +1100 >I don't know whether the gethostbyname() problem Robert is having is >related to PR 3622, but I think there is a problem with the default >login.conf. > >I had to lower openfiles settings to 256 because having it larger >breaks select(). It's been a while, so I'm a bit fuzzy on the details, >but I do remember that it was causing rxvt to fail.. a quick perusal >of the rxvt source indicates that it does: It breaks buggy applications. >I believe that it ends up obtaining the 1024 that was defined in login.conf, >but the FD_SETSIZE in sys/types.h is defined as 256. IIRC, select() bombs >out when nfds is > 256. Naive use of the FD_* macros doesn't work if nfds > FD_SETSIZE. The application should know about this and either not supports fd's >= FD_SETSIZE, or handle them somehow. The documented way is to #define FD_SETSIZE before including <sys/types.h>. The networking libraries use a more flexible way. >I suppose I should test this rather than just make the claim. Try this: > >#include <stdio.h> >#include <unistd.h> >#include <sys/types.h> >#include <sys/time.h> >#include <sys/select.h> > >void testselect(int num) >{ > fd_set fds; > struct timeval tv = {0, 0}; > > printf("testing select(%d,...)\n", num); > FD_ZERO(&fds); > if (select(num, &fds, &fds, &fds, &tv) < 0) { > perror("select()"); > } If nfds > FD_SETSIZE, in FreeBSD-2.2.0 and later versions, select() will probably succeed and scribble on the stack beyond the end of fds. In earlier versions, it rejects the request if nfds > 256. FD_SETSIZE happens to be 256 in 2.2.5 and 1024 in -current. Programs should not depend on this (but many probably do :-(). Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199712171730.JAA26387>