Re: poll(2) only can handle 256 fds?



On Mon, Mar 14, 2005 at 03:15:06AM +0100, Markus Lausser wrote:
On Fri, 2005-03-11 at 13:41, Gus Koppel wrote:
Iago Rubio wrote:

i get the message
  *** GLib *** : poll(2) failed due to: Invalid argument.
thousand times when running my application.
It seems that it happens if i have accepted 100 < x < 200
tcp connection from which i listen for input.

What can i do? I am using glib 2.6.0 on a linux system.

getrlimit(RLIMIT_NOFILES, ...) reports 1024 for both the current
and the max value. Also using setrlimit() doesn't solve the problem.

I've tried another application which also uses poll() (and no glib),
and it can process an array containing more than 256 entries.


There was a "sanity" check in older kernels that placed some limit on
the number of poll or select entries based on the number of open files
(the misguided assumption being that it wouldn't be valid to pass more
pollfds than open file descriptors). This might explain why your example
with polls on stdin only fails.
Anyway, generally glib shouldn't trigger this check/bug unless you end
up getting the same fd into the mainloop multiple times.

You might want to see if you are "leaking" io watches in your glib loop
and triggering this check.

Additionally you might want to consider upgrading your kernel.

  -jkl



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]