GNOME Bugzilla – Bug 707097
GSources created by GSocket do not handle G_IO_NVAL
Last modified: 2013-09-11 13:48:47 UTC
If you create a GInputStream out of a GTcpConnection and try to read asynchronously some data out of it and no data comes out immediatly and you decide to close that GTcpConnection. You can decide to gracefully end the connection by setting the "graceful-disconnect" property to TRUE. In that case the socket is shutdown() which stops the asynchronous read operation emitting the G_IO_HUP event on the file descriptor. If you device to not gracefully end the connection, the socket is just close(), which now makes the filedescriptor of that socket invalid. In that case the asynchronous read operation will never terminate because the GSource doesn't consider the G_IO_NVAL signal on the file descriptor a valid event to dispatch the callback and let the read operation terminate with an error. It also constantly wakes up the GMainLoop which leads to a 100% cpu consumption (https://bugs.freedesktop.org/show_bug.cgi?id=64923).
Created attachment 253569 [details] [review] gsocket: create sources handling G_IO_NVAL
i actually already fixed this in git while we were talking about it yesterday :)
Can we please cherry-pick this back to the stable branch as I tend to hit this once a day or so.
feel free to cherry-pick it, although i don't think there are any plans for another 2.36 release
Looks like people are experiencing this with gnome-online-account too : https://bugzilla.redhat.com/show_bug.cgi?id=1005619
hm, see also bug 707912; there actually is a bug in glib that ought to have been preventing this case from getting hit. (The attempt to close the stream when there was a read pending should have failed and returned a GError.)