Fix SoupSessionAsync to handle very early aborts better
authorDan Winship <danw@gnome.org>
Sun, 16 May 2010 07:31:38 +0000 (03:31 -0400)
committerDan Winship <danw@gnome.org>
Sun, 16 May 2010 12:27:55 +0000 (08:27 -0400)
commita87e5833024a21a4e2aa845e039121377e921738
treea646eea6535ab4d3b0f12354b30ad8149a9b08b8
parentbcd811894f44d2e5ccb0e213fd1c9e9ebf2c2bc3
Fix SoupSessionAsync to handle very early aborts better

If soup_session_abort() was called while we were doing async DNS,
things could get confused and it would end up trying to use a freed
SoupSocket. Fix that up by always properly using GCancellables during
SoupSocket connection, so that we can cancel any outstanding
operations if the socket is destroyed, and add a regression test for
that.

That then fixes a known leak in misc-test's early-abort case, but
makes it crash instead, so we fix that by using a weak pointer in
SoupSessionAsync to detect when the session has been destroyed before
the callback is invoked. This then creates/reveals additional leaks in
that test case, which require additional fixes.

The relevant APIs are obviously lousy (in the way most pre-gio async
APIs in GNOME were), but can't really be fixed at this point without
breaking ABI. To be fixed in the gio-based API...

https://bugzilla.gnome.org/show_bug.cgi?id=618641
libsoup/soup-connection.c
libsoup/soup-session-async.c
libsoup/soup-session.c
libsoup/soup-socket.c
tests/misc-test.c