Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Jun 1997 01:22:50 -0600 (MDT)
From:      Marc Slemko <marcs@znep.com>
To:        hackers@freebsd.org
Subject:   gethostbyname() and fds >255
Message-ID:  <Pine.BSF.3.95.970621011514.21696M-100000@alive.znep.com>

next in thread | raw e-mail | index | archive | help
If I run the following program:

#define FD_SETSIZE 1024
#include <fcntl.h>
#include <err.h>
#include <stdio.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

int main () {
	char s[1024];
	int i;
	struct hostent *h;


	for (i = 0; i < 400; i++) {
		sprintf(s, "test/%d", i);
		if (open(s, O_RDWR|O_CREAT, 0666) == -1)
			err(1, "open of %s failed", s);
		if (!(h = gethostbyname("www.worldgate.com"))) {
			herror("gethostbyname failed");
			exit(1);
		}

		h = gethostbyname("www.worldgate.com");
		printf("%d: host = %s (%s)\n", i, 
			inet_ntoa(*(struct in_addr *)(u_int *)h->h_addr), 
			h->h_name);
	}
	exit(0);
}

On 2.2-stable from a month or so ago with ulimit -n 2048 I get: 

0: host = 198.161.84.2 (valis.worldgate.com)
1: host = 198.161.84.2 (valis.worldgate.com)
2: host = 198.161.84.2 (valis.worldgate.com)
3: host = 198.161.84.2 (valis.worldgate.com)
[...]
249: host = 198.161.84.2 (valis.worldgate.com)
250: host = 198.161..84.2 (valis.worldgate.com)
251: host = 198.161.84.2 (valis.worldgate.com)
gethostbyname failed: Unknown host

For comparison, it works fine on BSD/OS 2.1.  Does it work in -current? 

Ideas?  If I remove the gethostbyname, I can open >255 fds without
problem.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95.970621011514.21696M-100000>