(mini_inetd): separate number of allocated sockets and number of
actual ones git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7828 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -92,7 +92,7 @@ mini_inetd (int port)
|
|||||||
int error, ret;
|
int error, ret;
|
||||||
struct addrinfo *ai, *a, hints;
|
struct addrinfo *ai, *a, hints;
|
||||||
char portstr[NI_MAXSERV];
|
char portstr[NI_MAXSERV];
|
||||||
int n, i;
|
int n, nalloc, i;
|
||||||
int *fds;
|
int *fds;
|
||||||
fd_set orig_read_set, read_set;
|
fd_set orig_read_set, read_set;
|
||||||
int max_fd = -1;
|
int max_fd = -1;
|
||||||
@@ -107,10 +107,10 @@ mini_inetd (int port)
|
|||||||
if (error)
|
if (error)
|
||||||
errx (1, "getaddrinfo: %s", gai_strerror (error));
|
errx (1, "getaddrinfo: %s", gai_strerror (error));
|
||||||
|
|
||||||
for (n = 0, a = ai; a != NULL; a = a->ai_next)
|
for (nalloc = 0, a = ai; a != NULL; a = a->ai_next)
|
||||||
++n;
|
++nalloc;
|
||||||
|
|
||||||
fds = malloc (n * sizeof(*fds));
|
fds = malloc (nalloc * sizeof(*fds));
|
||||||
if (fds == NULL)
|
if (fds == NULL)
|
||||||
errx (1, "mini_inetd: out of memory");
|
errx (1, "mini_inetd: out of memory");
|
||||||
|
|
||||||
@@ -134,6 +134,7 @@ mini_inetd (int port)
|
|||||||
freeaddrinfo (ai);
|
freeaddrinfo (ai);
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
errx (1, "no sockets");
|
errx (1, "no sockets");
|
||||||
|
n = i;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
read_set = orig_read_set;
|
read_set = orig_read_set;
|
||||||
|
Reference in New Issue
Block a user