On Tue, 2005-03-08 at 21:56, Markus Lausser wrote: > Hello, > > 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.
I've did some investigation, and it appears that glib runs into an endless loop when it tries to poll more than 256 fds at once. I've written a short test program which reproduces this behaviour on my system. Can anyone verify this? The Program: ------------ #include <stdlib.h> #include <glib.h> static GMainLoop* MainLoop = NULL; static gboolean io_invoke(GIOChannel* source, GIOCondition condition, gpointer data) { int* num = data; (void)source; (void)condition; g_log("TEST", G_LOG_LEVEL_DEBUG, "io invoke called %d", *num); *num = *num-1; return FALSE; } static gboolean add_channels(int* num) { int i1; g_log("TEST", G_LOG_LEVEL_DEBUG, "adding %d channels", *num); for (i1 = 0; i1 < *num; i1++) { GIOChannel* channel = g_io_channel_unix_new(0); g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, G_IO_IN | G_IO_HUP | G_IO_ERR, io_invoke, num, NULL); } return FALSE; } static gboolean end_program() { g_log("TEST", G_LOG_LEVEL_DEBUG, "ending program"); g_main_loop_quit(MainLoop); return FALSE; } int main(int argc, char** argv) { int num; if (argc != 2) { g_log("TEST", G_LOG_LEVEL_WARNING, "one integer argument required"); return -1; } num = atoi(argv[1]); MainLoop = g_main_loop_new(NULL, FALSE); g_timeout_add(1000, (GSourceFunc)add_channels, &num); g_timeout_add(10000, (GSourceFunc)end_program, NULL); g_main_loop_run(MainLoop); return 0; } ------------- Compile: $ gcc -Wall `pkg-config --cflags --libs glib-2.0` main.c -o test run without problems: ./test 256 run with endless loop: ./test 257 Markus. _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list