Date: Thu, 22 May 1997 15:06:05 -0700 From: Cabal95 <cabal95@dal.net> To: freebsd-questions@freebsd.org Cc: john@starfire.mn.org Subject: Re: bin/3622: gethostbyname fails for file descriptors above 255 Message-ID: <3384C34D.23AD@dal.net>
next in thread | raw e-mail | index | archive | help
john@starfire.mn.org wrote: > Number: 3622 > Category: bin > Synopsis: gethostbyname fails for file descriptors above 255 > > Description: > > gethostbyname() fails for a perfectly good domain name once a program > already has file descriptors 0-255 open. I have not yet tracked > this down to find if it is specific to gethostbyname, or if it > may be the underlying infrastructure, or possibly even into the kernel > (in which case the category specified for this report will be wrong). After compiling a debug version of FreeBSD 2.2.1-Release libc.a 3.0 and running your test program below through gdb 4.16, the specific cause of this problem appears to be caused by the following code in /usr/src/lib/libc/net/res_send.c(I'm sorry, line # not available) s = socket(PF_INET, SOCK_DGRAM, 0); ... if (s+1 > FD_SETSIZE) { Perror(stderr, "res_send: too many files"); _res_close(); goto next_ns; } When compiling the libs, FD_SETSIZE on most(all?) systems is 256, defined in /usr/include/sys/types.h. > Fix: One way I fixed this on my system was to recompile libc.a with FD_SETSIZE defined to a higher value. I used 1024 and have not had any of the described problems since doing that. Another way was to go into the /usr/src/lib/libc/net/res_send.c, take out: if (s+1 > FD_SETSIZE) { Perror(stderr, "res_send: too many files"); _res_close(); goto next_ns; } and change: select(s+1, &dsmask, (fd_set *)NULL, (fd_set *)NULL, &timeout) to: select(1, &dsmask, (fd_set *)NULL, (fd_set *)NULL, &timeout) This also works, but there may be problems i'm unaware of, since select() appears to be an internal kernel function, and I don't have the kernel source at this time. Although, from my programming experience on linux, you can call select() with FD's greater than FD_SETSIZE, just not a group of FD's who's total number is greater than FD_SETSIZE. But perhaps this is different under FreeBSD? Cabal95/Daniel
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3384C34D.23AD>