Date: Sun, 18 May 1997 18:57:01 -0500 (CDT) From: john@starfire.mn.org To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/3622: gethostbyname fails for file descriptors above 255 Message-ID: <199705182357.SAA10521@starfire.mn.org> Resent-Message-ID: <199705190000.RAA21732@hub.freebsd.org>
index | next in thread | raw e-mail
>Number: 3622
>Category: bin
>Synopsis: gethostbyname fails for file descriptors above 255
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: freebsd-bugs
>State: open
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sun May 18 17:00:01 PDT 1997
>Last-Modified:
>Originator: John Lind
>Organization:
Starfire Consulting Services, SkyPoint Communications, Inc.
>Release: FreeBSD 2.2.1-RELEASE i386
>Environment:
>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).
>How-To-Repeat:
The following program will reproduce the problem. Sample output
is given. Note that the same lookup is performed successfully
253 times before it fails.
--- sample output
www.freebsd.org: Unknown host
RLIMIT_NOFILE rlim_cur 2088
252: 255, /tmp/testghbn.02985
--- program source for testghlim.c
#include <stdio.h>
#include <unistd.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
int
test_ghbn(const char *dhn)
{
struct hostent *h;
extern int h_errno;
if( (h = gethostbyname(dhn)) == NULL ) {
herror(dhn);
return 1;
}
return 0;
}
char *progname;
void usage()
{
fprintf(stderr,"Usage: %s host.domain.name\n");
exit(99);
}
main(int argc, char **argv)
{
int idx;
int fd;
struct rlimit info;
char tfn[32];
char *hostdn;
progname = *argv;
if (argc < 2)
usage();
hostdn = argv[1];
getrlimit(RLIMIT_NOFILE,&info);
info.rlim_cur = info.rlim_max;
setrlimit(RLIMIT_NOFILE,&info);
getrlimit(RLIMIT_NOFILE,&info);
printf("RLIMIT_NOFILE rlim_cur %d\n",info.rlim_cur);
for (idx=0; idx < 300; idx++) {
strcpy(tfn,"/tmp/testghbn.XXXXX");
fd = mkstemp(tfn);
unlink(tfn);
if (test_ghbn(hostdn)) {
printf("%d: %d, %s\n", idx, fd, tfn);
break;
}
}
exit(0);
}
>Fix:
No known fix at this time. As I urgently need this to work to
get Apache 1.1.3 or 1.2b10 running for a multi-homed web site
of about 300 virtual hosts, I will begin attempting to build
debugging versions of the standard library routines as soon
as I find something to eat...
>Audit-Trail:
>Unformatted:
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199705182357.SAA10521>
