After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 616855 - GSocketConnection: don't close the socket if it's still reffed
GSocketConnection: don't close the socket if it's still reffed
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-04-26 15:02 UTC by Dan Winship
Modified: 2010-06-22 19:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GSocketConnection: don't close the socket if it's still reffed (2.67 KB, patch)
2010-04-26 15:02 UTC, Dan Winship
committed Details | Review

Description Dan Winship 2010-04-26 15:02:17 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.
Comment 1 Dan Winship 2010-04-26 15:02:19 UTC
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.
Comment 2 Dan Winship 2010-06-22 19:27:01 UTC
Attachment 159611 [details] pushed as a0e1b22 - GSocketConnection: don't close the socket if it's still reffed