Re: Using Poll on RedHat Enterprise

From: Kurtis D. Rader (krader_at_skepticism.us)
Date: 12/12/04


Date: Sat, 11 Dec 2004 19:53:43 -0800

On Fri, 10 Dec 2004 14:01:22 +0100, Michael Gebhart wrote:

> I have one special problem using poll() on a RedHat Enterprise Server.

Please be precise. Which Red Hat release and kernel version?

> int poll(struct pollfd *ufds, unsigned int nfds, int timeout);
>
> On some systems it works really good. First I have to set the number of
> max. open files to 5000 with ulimit -n or setrlimit and then it rocks :)
>
> But on a RedHat Enterprise system I have the problem, that poll returns
> an error 22. Error22 means:

Shameless plug: Companies like IBM provide excellent support and will be
happy to provide timely answers to such questions. Yes, I'm a level 3
Linux support engineer at IBM so I'm a wee bit biased :-)

I'll assume you are asking about RHEL 3 with kernel version 2.4.21-20.
Looking at the source (from sys_poll() in fs/select.c) the first condition
which results in EINVAL is:

        if (nfds > current->files->max_fdset && nfds > OPEN_MAX)
                return -EINVAL;

The second predicate is important since OPEN_MAX is defined to be 256 and
you're specifying a larger value. I suspect you're passing a value for the
second poll() argument (nfds) that is greater than the current size of the
file descriptor array for your task. Are you checking that the
setrlimit(RLIMIT_NOFILE) call is succeeding? The default hard limit is
1024 file descriptors.

Note that this behavior is not specific to Red Hat Enterprise Linux. The
same check is present in generic kernel.org kernels (including the latest
bleeding edge 2.6 kernel).



Relevant Pages