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 596074 - Session leak when aborted before queued message finished
Session leak when aborted before queued message finished
Status: RESOLVED FIXED
Product: libsoup
Classification: Core
Component: API
2.27.x
Other All
: Normal major
: ---
Assigned To: libsoup-maint@gnome.bugs
libsoup-maint@gnome.bugs
Depends on:
Blocks:
 
 
Reported: 2009-09-23 12:52 UTC by Arnout Vandecappelle
Modified: 2009-11-22 14:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Session leak test case with queue-abort sequence (2.78 KB, text/x-csrc)
2009-09-23 12:52 UTC, Arnout Vandecappelle
  Details
Proposed patch (against 2.27.5) (4.02 KB, patch)
2009-09-23 14:34 UTC, Arnout Vandecappelle
none Details | Review
Don't leak session if message is cancelled during socket connection (4.26 KB, patch)
2009-10-12 16:42 UTC, Dan Winship
committed Details | Review

Description Arnout Vandecappelle 2009-09-23 12:52:24 UTC
Created attachment 143787 [details]
Session leak test case with queue-abort sequence

When queueing a message on an async session and aborting the session before the
message gets a response, the session is leaked.

(I referred to this situation in Bug #498509, but now have finally found the
time to really study it.)

The attached test case shows the problem (with libsoup-2.27.5).
Comment 1 Arnout Vandecappelle 2009-09-23 13:35:37 UTC
I think it's in soup_socket_disconnect(): idle_connect_callback isn't called upon disconnect, so the connect callback (which unrefs the session) doesn't get invoked.  Also sacd isn't freed.
Comment 2 Dan Winship 2009-09-23 14:32:13 UTC
I think it shouldn't be reffing the session that it passes to soup_connection_connect_async, because that's backwards; we don't want the session to stick around because a connection is in progress, we want the connection to be cancelled if the session is disposed().

But just making that change causes proxy-test to crash, so it needs a little work
Comment 3 Arnout Vandecappelle 2009-09-23 14:34:23 UTC
Created attachment 143802 [details] [review]
Proposed patch (against 2.27.5)

The attached patch fixes the test at least, by calling idle_connect_result() when disconnecting.  I tried to use soup_add_completion() for it, but that didn't seem to work (it never got called, even with the g_main_context_iteration in the test).

There are a lot of changes because the sacd had to be added to SoupSocketPrivate.

Note that the patch is against 2.27.5, but it applies with some offset to git HEAD.
Comment 4 Arnout Vandecappelle 2009-09-23 15:28:27 UTC
(In reply to comment #2)
> I think it shouldn't be reffing the session that it passes to
> soup_connection_connect_async, because that's backwards; we don't want the
> session to stick around because a connection is in progress, we want the
> connection to be cancelled if the session is disposed().

The following comment in got_connection makes me think it's reasonable to ref the session:

	/* Even if the connection failed, we run the queue, since
	 * there may have been messages waiting for the connection
	 * count to go down.
	 */
Comment 5 Dan Winship 2009-10-12 16:42:36 UTC
Created attachment 145287 [details] [review]
Don't leak session if message is cancelled during socket connection

fixes the provided test case and doesn't break any existing test cases.

It's tricky to make a good test case for this. (I can't find anything that
actually says 1.1.1.1 is guaranteed to have a route pointing to it.) However,
some changes for bug 598163 will make it easier to test this reliably.
Comment 6 Dan Winship 2009-11-22 14:01:22 UTC
Attachment 145287 [details] pushed as 3076f99 - Don't leak session if message is cancelled during socket connection

fixed in master. will eventually end up in libsoup 2.28.2 in a few weeks