The code did not handle EOF (0 byte read) correctly. This can e.g. cause an infinite loop if an incorrect socks proxy is configured.
Add the appropriate checks and return an G_IO_ERROR_CONNECTION_CLOSED error if EOF is encountered.
So yeah, I accidentally put an HTTPS proxy into the SOCKS field. The result were 3 processes just spinning CPU here (2x webkitgtk + gsd-print-notifications). Not nice, but I think this should solve it.