[evolution-patches] soup server patch



Hi,

Attached is a patch which fixes a CPU pegging when you connect to an
HTTPS SoupServer and issue an invalid request (like a plain HTTP
request).  Without this patch, Soup thinks that it can reuse the socket
(because it is an HTTP 1.1 server) and attaches a watch with the invalid
data still on the socket.  This patch makes Soup immediately hang up the
socket whenever an error occurs.

Joe
? soup.patch
Index: soup-server.c
===================================================================
RCS file: /cvs/gnome/libsoup/libsoup/soup-server.c,v
retrieving revision 1.35.2.1
diff -u -p -u -r1.35.2.1 soup-server.c
--- soup-server.c	8 Sep 2003 14:54:31 -0000	1.35.2.1
+++ soup-server.c	18 Sep 2003 19:59:46 -0000
@@ -244,6 +244,23 @@ check_close_connection (SoupMessage *msg
 } /* check_close_connection */
 
 static void
+close_connection (SoupMessage *msg)
+{
+	SoupSocket *server_sock = msg->priv->server_sock;
+
+	if (server_sock) {
+		GIOChannel *chan;
+
+		chan = soup_socket_get_iochannel (server_sock);
+		
+		g_io_channel_close (chan);
+		soup_socket_unref (server_sock);
+
+		msg->priv->server_sock = NULL;
+	}
+}
+
+static void
 destroy_message (SoupMessage *msg)
 {
 	SoupServer *server = msg->priv->server;
@@ -261,8 +278,7 @@ destroy_message (SoupMessage *msg)
 		 * using HTTP/1.1 and "Connection: close" was specified.
 		 */
 		if (check_close_connection (msg)) {
-			g_io_channel_close (chan);
-			soup_socket_unref (server_sock);
+			close_connection (msg);
 		}
 		else {
 			/*
@@ -307,6 +323,7 @@ error_cb (gboolean body_started, gpointe
 {
 	SoupMessage *msg = user_data;
 
+	close_connection (msg);
 	destroy_message (msg);
 }
 


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