g_io_channel_read_line and nonblocking IO
Submitted by Balazs Scheidler
Link to original bug (#126266)
Description
We are trying to read lines from a nonblocking stream and we are encountering 100% CPU time usage.
We created a watch using g_io_channel_create_watch(G_IO_IN) and then attached a read callback which calls g_io_channel_read_line.
When a line without newline is present in the GIOChannel's buffer the poll loop maxes out the processor until a complete line is available.
The problem seems to be that g_io_unix_prepare assumes readability when any characters are present in the buffer and then g_io_channel_read_line returns G_IO_STATUS_AGAIN as no complete lines are available.
The solution would be a new option to GIOChannel (or Watch) that we want line based polling.
Version: 2.0.x