c_glib: fix infinite loop in socket read function