Try to apply some order to the iochannel refcounting...
authorJoe Shaw <joe@ximian.com>
Thu, 27 Feb 2003 22:12:46 +0000 (22:12 +0000)
committerJoe Shaw <joeshaw@src.gnome.org>
Thu, 27 Feb 2003 22:12:46 +0000 (22:12 +0000)
2003-02-27  Joe Shaw  <joe@ximian.com>

Try to apply some order to the iochannel refcounting...

* configure.in: Bump up to 1.99.11.

* soup-context.c (soup_connection_get_iochannel): The connections
needs to own a reference to the iochannel!  If we're using HTTPS,
release the ref we get from soup_socket_get_iochannel and replace
it with the ref we get from soup_ssl_get_iochannel().  Then,
always ref the channel that we return (ugh, but that's the soup
way).
(connection_free): Release the connection's ref to the iochannel.

* soup-ssl.c (soup_ssl_get_iochannel_real): Ref the iochannel.
The reference we pass back will be owned by the connection.
(soup_ssl_hup_waitpid): Release our ref.

ChangeLog
configure.in
libsoup/soup-context.c
libsoup/soup-ssl.c

index d810bba..5b62cd0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2003-02-27  Joe Shaw  <joe@ximian.com>
 
+       Try to apply some order to the iochannel refcounting...
+
+       * configure.in: Bump up to 1.99.11.
+
+       * soup-context.c (soup_connection_get_iochannel): The connections
+       needs to own a reference to the iochannel!  If we're using HTTPS,
+       release the ref we get from soup_socket_get_iochannel and replace
+       it with the ref we get from soup_ssl_get_iochannel().  Then,
+       always ref the channel that we return (ugh, but that's the soup
+       way).
+       (connection_free): Release the connection's ref to the iochannel.
+
+       * soup-ssl.c (soup_ssl_get_iochannel_real): Ref the iochannel.
+       The reference we pass back will be owned by the connection.
+       (soup_ssl_hup_waitpid): Release our ref.
+
+2003-02-27  Joe Shaw  <joe@ximian.com>
+
        * configure.in: Bump up to 1.99.10.
 
        * soup-ssl.c (soup_ssl_get_iochannel_real): Ref the iochannel,
index c455d74..b7fd3e2 100644 (file)
@@ -4,7 +4,7 @@ dnl *******************************************
 
 AC_INIT(libsoup/soup.h)
 
-AM_INIT_AUTOMAKE(libsoup, 1.99.10)
+AM_INIT_AUTOMAKE(libsoup, 1.99.11)
 AM_CONFIG_HEADER(config.h)
 AM_MAINTAINER_MODE
 AC_PROG_MAKE_SET
index 9811d4f..d834932 100644 (file)
@@ -257,6 +257,7 @@ connection_free (SoupConnection *conn)
        conn->server->connections =
                g_slist_remove (conn->server->connections, conn);
 
+       g_io_channel_unref (conn->channel);
        soup_context_unref (conn->context);
        soup_socket_unref (conn->socket);
        g_source_remove (conn->death_tag);
@@ -623,10 +624,16 @@ soup_connection_get_iochannel (SoupConnection *conn)
 
                soup_connection_setup_socket (conn->channel);
 
-               if (conn->context->uri->protocol == SOUP_PROTOCOL_HTTPS)
-                       conn->channel = soup_ssl_get_iochannel (conn->channel);
-       } else
-               g_io_channel_ref (conn->channel);
+               if (conn->context->uri->protocol == SOUP_PROTOCOL_HTTPS) {
+                       GIOChannel *ssl_chan;
+
+                       ssl_chan = soup_ssl_get_iochannel (conn->channel);
+                       g_io_channel_unref (conn->channel);
+                       conn->channel = ssl_chan;
+               }
+       }
+
+       g_io_channel_ref (conn->channel);
 
        return conn->channel;
 }
index 52ca4e1..6a8659a 100644 (file)
@@ -49,13 +49,7 @@ soup_ssl_hup_waitpid (GIOChannel *source, GIOCondition condition, gpointer user_
 
        waitpid (ssl_info->ppid, NULL, 0);
        
-       /*
-        * FIXME: The refcounting for these iochannels is totally
-        * broken.  If we have this unref below, it causes crashes
-        * when using HTTPS with a proxy.  Sigh.  It's better to
-        * just leak.
-        */
-       /* g_io_channel_unref (ssl_info->real_sock); */
+       g_io_channel_unref (ssl_info->real_sock);
        g_free (ssl_info);
 
        return FALSE;
@@ -74,7 +68,6 @@ soup_ssl_get_iochannel_real (GIOChannel *sock, SoupSSLType type)
        g_return_val_if_fail (sock != NULL, NULL);
 
        g_io_channel_ref (sock);
-
        if (!(sock_fd = g_io_channel_unix_get_fd (sock))) goto ERROR_ARGS;
        flags = fcntl(sock_fd, F_GETFD, 0);
        fcntl (sock_fd, F_SETFD, flags & ~FD_CLOEXEC);