"David S. Miller" wrote:
>
> From: Tim Hockin <thockin@sun.com>
> Date: Tue, 14 Aug 2001 16:53:43 -0700
>
> The standard says negative fd's are ignored. We get that right. What we
> are left with is an overly paranoid check against max_fds. This check
> should go away. You should be able to pass in up to your rlimit fds, and
> let negative ones (holes or tails) be ignored.
>
> I am saying there is no problem.
>
> In both cases, for a properly written application we ignore the
> invalid fds. The behavior is identical both before and after
> your change, so there is no reason to make it.
But for an application that (imho) is poorly written but IS COMPLIANT, it
fails.
This program is compliant, if your ulimit -n is maxxed out at 1048576.
I'm not saying it is good design, but it is compliant. The patch hurts
nothing and makes poll() that little bit more friendly.
#include <stdio.h>
#include <sys/poll.h>
#include <errno.h>
#include <string.h>
int
main(void)
{
static struct pollfd ar[1024*1024];
int size = sizeof(ar)/sizeof(*ar);
int i;
for (i = 0; i < size; i++)
ar[i].fd = -1;
ar[1000000].fd = 0;
ar[1000000].events = POLLIN;
i = poll(ar, size, -1);
printf("return = %d (%s)\n", i, i?strerror(errno):"success");
return 0;
}
-- Tim Hockin Systems Software Engineer Sun Microsystems, Cobalt Server Appliances thockin@sun.com - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Wed Aug 15 2001 - 21:00:55 EST