[libsoup] SoupSocket: don't emit "readable" on disconnect for blocking sockets



commit d0d534568c97271e03a0e9f9c16a0966fb50b97a
Author: Dan Winship <danw gnome org>
Date:   Thu Jul 19 08:49:55 2012 -0400

    SoupSocket: don't emit "readable" on disconnect for blocking sockets
    
    "readable" and "writable" are only supposed to be emitted for
    non-blocking sockets, but we were emitting "readable" on disconnect
    for all sockets.
    
    In libsoup 2.38 and earlier, this could cause a crash if a message in
    a SoupSessionSync failed at certain points, since the code wasn't
    expecting to end up in io_read(). The current code no longer has this
    problem (since soup-message-io no longer uses the SoupSocket signals),
    but other external users of SoupSocket might.

 libsoup/soup-socket.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/libsoup/soup-socket.c b/libsoup/soup-socket.c
index 2ac359d..5a88907 100644
--- a/libsoup/soup-socket.c
+++ b/libsoup/soup-socket.c
@@ -1242,8 +1242,10 @@ soup_socket_disconnect (SoupSocket *sock)
 	 */
 	g_object_ref (sock);
 
-	/* Give all readers a chance to notice the connection close */
-	g_signal_emit (sock, signals[READABLE], 0);
+	if (priv->non_blocking) {
+		/* Give all readers a chance to notice the connection close */
+		g_signal_emit (sock, signals[READABLE], 0);
+	}
 
 	/* FIXME: can't disconnect until all data is read */
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]