Answer to: What causes GLib I/O Channels operations to use up 100% CPU in GTK+ app.?



[Moving gtk-app-devel-list gnome org to BCC. See earlier post for test code.]

At 02:41 AM 10/12/2006, Daniel Yek wrote:
At 02:36 AM 10/12/2006, Daniel Yek wrote:
Could somebody enlighten me why after an I/O Channel operation (g_io_channel_shutdown() here), the GTK+ program started to use up 100% CPU?

Is it monitoring something? Do I need to undo g_io_add_watch() somehow? What operation is needed to not get into such situation?

Figured that out myself.

1. Closing the write-end of the pipe caused GIOConditoin of G_IO_HUP being generated when being polled. Failing to intercept and react to it by removing the Channel watch causes infinite GIOConditoin of G_IO_HUP "notification attempt" and hence 100% CPU usage. There should be an assert to guard this infinite loop in channel monitoring.

2. Closing the read-end of the pipe caused GIOConditoin of G_IO_NVAL when being polled. Failing to intercept and react to it by removing the Channel watch causes infinite GIOConditoin of G_IO_NVAL "notification attempt".

3. Shutting down the I/O Channel without removing Channel Watch again causes condition #2 above.

These seem like rough edges to me; (or was that simply my fault of not programming it right earlier?)

Is there any developer willing to insert asserts or implement default handling where appropriate?

Thanks.


--
Daniel Yek




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