GNOME Bugzilla – Bug 616855
GSocketConnection: don't close the socket if it's still reffed
Last modified: 2010-06-22 19:27:04 UTC
this came up in the summer of code I was mentoring last year; the student wanted to use GSocketClient to do the dirty work of making a connection, but then wanted just a GSocket, not a GSocketConnection. Unfortunately, if you destroy the GSocketConnection, it always closes the underlying socket as well. This changes it to only close the socket if the socket is destroyed. There is no plausible reason for keeping a closed GSocket around, so the only effect this patch is likely to have on existing code is that if someone was leaking GSockets, this would turn the memory leak into a file descriptor leak too. I'm not especially happy about the implementation. Suggestions welcome.
Created attachment 159611 [details] [review] GSocketConnection: don't close the socket if it's still reffed When disposing a GSocketConnection, don't explicitly close the underlying GSocket. The GSocket will close itself if it gets destroyed, and if it doesn't get destroyed, that presumably means the app still wants to use it. Eg, this lets you use GSocketClient to create a GSocketConnection, and then take the GSocket and destroy the GSocketConnection.
Attachment 159611 [details] pushed as a0e1b22 - GSocketConnection: don't close the socket if it's still reffed