SoupConnection: fix a race condition with non-keepalive messages
authorDan Winship <danw@gnome.org>
Tue, 2 Oct 2012 12:57:52 +0000 (08:57 -0400)
committerDan Winship <danw@gnome.org>
Thu, 18 Oct 2012 16:44:26 +0000 (12:44 -0400)
commitaa8e1dc5127b56bd96e9d3068a6bfeb7c1a07a94
tree0032f20356985fdfa51fb61ed9862c07774e4839
parent0778d818235e1b16eebea351019c3c4d72941d30
SoupConnection: fix a race condition with non-keepalive messages

When a SoupSession sets a connection back to IDLE on a non-keepalive
message, the connection then disconnects itself. However, it had been
briefly setting its state to IDLE before disconnecting. Although this
wasn't supposed to be observable (it doesn't emit a notification), in
a SoupSessionSync, it could be observed by another thread, which might
then try to claim the connection to send another request on, causing
problems when the first thread then disconnected it.

Fix this by inlining clear_current_item() into
soup_connection_set_state() and reordering the code to not change
priv->state until after deciding whether or not it's going to
disconnect.

https://bugzilla.gnome.org/show_bug.cgi?id=684238
libsoup/soup-connection.c