/* Initialize file descriptor set */
FD_ZERO (&readset);
- int *pi_end;
+ int *pi_end = pi_fd;
for (const int *pi = pi_fd; *pi != -1; pi++)
{
int fd = *pi;
struct timeval tv = { 0, b_block ? 500000 : i_wait };
- int val = select (maxfd, &readset, NULL, NULL, &tv);
+ int val = select (maxfd + 1, &readset, NULL, NULL, &tv);
if (val == 0)
{
if (b_block)
--pi_end;
memmove (pi_fd, pi_fd + 1, pi_end - pi_fd);
*pi_end = *pi;
+ msg_Dbg (p_this, "accepted socket %d (from socket %d)", fd, *pi);
+ return fd;
}
}