libsoup r1171 - in branches/gnome-2-24: . docs/reference libsoup tests



Author: danw
Date: Wed Oct  1 20:13:43 2008
New Revision: 1171
URL: http://svn.gnome.org/viewvc/libsoup?rev=1171&view=rev

Log:
pullups from trunk


Modified:
   branches/gnome-2-24/ChangeLog
   branches/gnome-2-24/docs/reference/libsoup-2.4-docs.sgml
   branches/gnome-2-24/docs/reference/libsoup-2.4-sections.txt
   branches/gnome-2-24/docs/reference/libsoup-2.4.types
   branches/gnome-2-24/libsoup/soup-auth-manager-ntlm.c
   branches/gnome-2-24/libsoup/soup-auth-manager.c
   branches/gnome-2-24/libsoup/soup-cookie-jar.c
   branches/gnome-2-24/libsoup/soup-cookie.c
   branches/gnome-2-24/libsoup/soup-cookie.h
   branches/gnome-2-24/libsoup/soup-dns.c
   branches/gnome-2-24/libsoup/soup-headers.c
   branches/gnome-2-24/libsoup/soup-logger.c
   branches/gnome-2-24/libsoup/soup-message-body.h
   branches/gnome-2-24/libsoup/soup-message.h
   branches/gnome-2-24/libsoup/soup-misc.h
   branches/gnome-2-24/libsoup/soup-session-async.c
   branches/gnome-2-24/libsoup/soup-session-feature.c
   branches/gnome-2-24/libsoup/soup-session-feature.h
   branches/gnome-2-24/libsoup/soup-session.c
   branches/gnome-2-24/libsoup/soup-xmlrpc.c
   branches/gnome-2-24/libsoup/soup-xmlrpc.h
   branches/gnome-2-24/tests/auth-test.c
   branches/gnome-2-24/tests/chunk-test.c
   branches/gnome-2-24/tests/context-test.c
   branches/gnome-2-24/tests/continue-test.c
   branches/gnome-2-24/tests/libsoup.supp
   branches/gnome-2-24/tests/misc-test.c
   branches/gnome-2-24/tests/ntlm-test.c
   branches/gnome-2-24/tests/pull-api.c
   branches/gnome-2-24/tests/redirect-test.c
   branches/gnome-2-24/tests/test-utils.c
   branches/gnome-2-24/tests/test-utils.h
   branches/gnome-2-24/tests/xmlrpc-test.c

Modified: branches/gnome-2-24/docs/reference/libsoup-2.4-docs.sgml
==============================================================================
--- branches/gnome-2-24/docs/reference/libsoup-2.4-docs.sgml	(original)
+++ branches/gnome-2-24/docs/reference/libsoup-2.4-docs.sgml	Wed Oct  1 20:13:43 2008
@@ -20,6 +20,8 @@
     <xi:include href="xml/soup-auth-domain.xml"/>
     <xi:include href="xml/soup-auth-domain-basic.xml"/>
     <xi:include href="xml/soup-auth-domain-digest.xml"/>
+    <xi:include href="xml/soup-cookie.xml"/>
+    <xi:include href="xml/soup-cookie-jar.xml"/>
     <xi:include href="xml/soup-logger.xml"/>
     <xi:include href="xml/soup-message.xml"/>
     <xi:include href="xml/soup-message-headers.xml"/>

Modified: branches/gnome-2-24/docs/reference/libsoup-2.4-sections.txt
==============================================================================
--- branches/gnome-2-24/docs/reference/libsoup-2.4-sections.txt	(original)
+++ branches/gnome-2-24/docs/reference/libsoup-2.4-sections.txt	Wed Oct  1 20:13:43 2008
@@ -352,6 +352,12 @@
 <SUBSECTION>
 soup_session_get_async_context
 <SUBSECTION>
+SoupSessionFeature
+soup_session_add_feature
+soup_session_add_feature_by_type
+soup_session_remove_feature
+soup_session_remove_feature_by_type
+<SUBSECTION>
 SOUP_SESSION_PROXY_URI
 SOUP_SESSION_MAX_CONNS
 SOUP_SESSION_MAX_CONNS_PER_HOST
@@ -361,6 +367,9 @@
 SOUP_SESSION_TIMEOUT
 SOUP_SESSION_IDLE_TIMEOUT
 SOUP_SESSION_USER_AGENT
+SOUP_SESSION_ADD_FEATURE
+SOUP_SESSION_ADD_FEATURE_BY_TYPE
+SOUP_SESSION_REMOVE_FEATURE_BY_TYPE
 <SUBSECTION Standard>
 SOUP_IS_SESSION
 SOUP_IS_SESSION_CLASS
@@ -370,6 +379,17 @@
 SOUP_TYPE_SESSION
 SoupSessionClass
 soup_session_get_type
+<SUBSECTION Private>
+soup_session_feature_attach
+soup_session_feature_detach
+SoupSessionFeatureInterface
+soup_session_feature_get_type
+SOUP_SESSION_FEATURE
+SOUP_SESSION_FEATURE_CLASS
+SOUP_SESSION_FEATURE_GET_CLASS
+SOUP_IS_SESSION_FEATURE
+SOUP_IS_SESSION_FEATURE_CLASS
+SOUP_TYPE_SESSION_FEATURE
 </SECTION>
 
 <SECTION>
@@ -511,6 +531,7 @@
 SOUP_URI_SCHEME_HTTP
 SOUP_URI_SCHEME_HTTPS
 soup_uri_uses_default_port
+SOUP_URI_VALID_FOR_HTTP
 <SUBSECTION>
 soup_uri_set_scheme
 soup_uri_set_user
@@ -538,6 +559,8 @@
 soup_date_new_from_now
 soup_date_to_string
 soup_date_to_time_t
+soup_date_to_timeval
+soup_date_is_past
 soup_date_free
 <SUBSECTION>
 soup_form_decode
@@ -558,6 +581,7 @@
 soup_header_free_list
 soup_header_contains
 soup_header_parse_param_list
+soup_header_parse_semi_param_list
 soup_header_free_param_list
 <SUBSECTION>
 soup_str_case_equal
@@ -656,3 +680,56 @@
 SOUP_LOGGER_GET_CLASS
 SOUP_TYPE_LOGGER
 </SECTION>
+
+<SECTION>
+<FILE>soup-cookie</FILE>
+<TITLE>SoupCookie</TITLE>
+SoupCookie
+soup_cookie_new
+soup_cookie_parse
+soup_cookie_free
+<SUBSECTION>
+soup_cookie_set_name
+soup_cookie_set_value
+soup_cookie_set_domain
+soup_cookie_set_path
+soup_cookie_set_max_age
+SOUP_COOKIE_MAX_AGE_ONE_HOUR
+SOUP_COOKIE_MAX_AGE_ONE_DAY
+SOUP_COOKIE_MAX_AGE_ONE_WEEK
+SOUP_COOKIE_MAX_AGE_ONE_YEAR
+soup_cookie_set_expires
+soup_cookie_set_secure
+soup_cookie_set_http_only
+<SUBSECTION>
+soup_cookie_applies_to_uri
+<SUBSECTION>
+soup_cookie_to_cookie_header
+soup_cookie_to_set_cookie_header
+<SUBSECTION>
+soup_cookies_from_request
+soup_cookies_from_response
+soup_cookies_to_request
+soup_cookies_to_response
+soup_cookies_to_cookie_header
+soup_cookies_free
+</SECTION>
+
+<SECTION>
+<FILE>soup-cookie-jar</FILE>
+<TITLE>SoupCookieJar</TITLE>
+SoupCookieJar
+soup_cookie_jar_new
+soup_cookie_jar_save
+soup_cookie_jar_get_cookies
+soup_cookie_jar_set_cookie
+<SUBSECTION Standard>
+SoupCookieJarClass
+SOUP_COOKIE_JAR
+SOUP_COOKIE_JAR_CLASS
+SOUP_COOKIE_JAR_GET_CLASS
+SOUP_IS_COOKIE_JAR
+SOUP_IS_COOKIE_JAR_CLASS
+SOUP_TYPE_COOKIE_JAR
+soup_cookie_jar_get_type
+</SECTION>

Modified: branches/gnome-2-24/docs/reference/libsoup-2.4.types
==============================================================================
--- branches/gnome-2-24/docs/reference/libsoup-2.4.types	(original)
+++ branches/gnome-2-24/docs/reference/libsoup-2.4.types	Wed Oct  1 20:13:43 2008
@@ -5,10 +5,13 @@
 soup_auth_domain_get_type
 soup_auth_domain_basic_get_type
 soup_auth_domain_digest_get_type
+soup_cookie_jar_get_type
+soup_logger_get_type
 soup_message_get_type
 soup_server_get_type
 soup_session_get_type
 soup_session_sync_get_type
 soup_session_async_get_type
+soup_session_feature_get_type
 soup_socket_get_type
 

Modified: branches/gnome-2-24/libsoup/soup-auth-manager-ntlm.c
==============================================================================
--- branches/gnome-2-24/libsoup/soup-auth-manager-ntlm.c	(original)
+++ branches/gnome-2-24/libsoup/soup-auth-manager-ntlm.c	Wed Oct  1 20:13:43 2008
@@ -35,7 +35,7 @@
 
 G_DEFINE_TYPE_WITH_CODE (SoupAuthManagerNTLM, soup_auth_manager_ntlm, SOUP_TYPE_AUTH_MANAGER,
 			 G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
-						soup_auth_manager_ntlm_session_feature_init));
+						soup_auth_manager_ntlm_session_feature_init))
 
 enum {
 	PROP_0,

Modified: branches/gnome-2-24/libsoup/soup-auth-manager.c
==============================================================================
--- branches/gnome-2-24/libsoup/soup-auth-manager.c	(original)
+++ branches/gnome-2-24/libsoup/soup-auth-manager.c	Wed Oct  1 20:13:43 2008
@@ -40,7 +40,7 @@
 
 G_DEFINE_TYPE_WITH_CODE (SoupAuthManager, soup_auth_manager, G_TYPE_OBJECT,
 			 G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
-						soup_auth_manager_session_feature_init));
+						soup_auth_manager_session_feature_init))
 
 typedef struct {
 	SoupSession *session;

Modified: branches/gnome-2-24/libsoup/soup-cookie-jar.c
==============================================================================
--- branches/gnome-2-24/libsoup/soup-cookie-jar.c	(original)
+++ branches/gnome-2-24/libsoup/soup-cookie-jar.c	Wed Oct  1 20:13:43 2008
@@ -21,7 +21,7 @@
 
 /**
  * SECTION:soup-cookie-jar
- * @short_description: 
+ * @short_description: Automatic cookie handling for #SoupSession
  *
  * A #SoupCookieJar stores #SoupCookie<!-- -->s and arrange for them
  * to be sent with the appropriate #SoupMessage<!-- -->s.
@@ -43,7 +43,7 @@
 
 G_DEFINE_TYPE_WITH_CODE (SoupCookieJar, soup_cookie_jar, G_TYPE_OBJECT,
 			 G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
-						soup_cookie_jar_session_feature_init));
+						soup_cookie_jar_session_feature_init))
 
 typedef struct {
 	GHashTable *domains;

Modified: branches/gnome-2-24/libsoup/soup-cookie.c
==============================================================================
--- branches/gnome-2-24/libsoup/soup-cookie.c	(original)
+++ branches/gnome-2-24/libsoup/soup-cookie.c	Wed Oct  1 20:13:43 2008
@@ -34,6 +34,9 @@
  * url="http://msdn2.microsoft.com/en-us/library/ms533046.aspx";>Microsoft's
  * HttpOnly extension attribute</ulink>, and observed real-world usage
  * (and, in particular, based on what Firefox does).
+ *
+ * To have a #SoupSession handle cookies for your appliction
+ * automatically, use a #SoupCookieJar.
  **/
 
 /**
@@ -391,13 +394,13 @@
 
 /**
  * soup_cookie_parse:
- * @cookie: a cookie string (eg, the value of a Set-Cookie header)
+ * @header: a cookie string (eg, the value of a Set-Cookie header)
  * @origin: origin of the cookie, or %NULL
  *
- * Parses @cookie and returns a #SoupCookie. (If @cookie contains
+ * Parses @header and returns a #SoupCookie. (If @header contains
  * multiple cookies, only the first one will be parsed.)
  *
- * If @cookie does not have "path" or "domain" attributes, they will
+ * If @header does not have "path" or "domain" attributes, they will
  * be defaulted from @origin. If @origin is %NULL, path will default
  * to "/", but domain will be left as %NULL. Note that this is not a
  * valid state for a #SoupCookie, and you will need to fill in some
@@ -504,6 +507,31 @@
 }
 
 /**
+ * SOUP_COOKIE_MAX_AGE_ONE_HOUR:
+ *
+ * A constant corresponding to 1 hour, for use with soup_cookie_new()
+ * and soup_cookie_set_max_age().
+ **/
+/**
+ * SOUP_COOKIE_MAX_AGE_ONE_DAY:
+ *
+ * A constant corresponding to 1 day, for use with soup_cookie_new()
+ * and soup_cookie_set_max_age().
+ **/
+/**
+ * SOUP_COOKIE_MAX_AGE_ONE_WEEK:
+ *
+ * A constant corresponding to 1 week, for use with soup_cookie_new()
+ * and soup_cookie_set_max_age().
+ **/
+/**
+ * SOUP_COOKIE_MAX_AGE_ONE_YEAR:
+ *
+ * A constant corresponding to 1 year, for use with soup_cookie_new()
+ * and soup_cookie_set_max_age().
+ **/
+
+/**
  * soup_cookie_set_expires:
  * @cookie: a #SoupCookie
  * @expires: the new expiration time, or %NULL
@@ -656,7 +684,7 @@
  *
  * Parses @msg's Set-Cookie response headers and returns a #GSList of
  * #SoupCookie<!-- -->s. Cookies that do not specify "path" or
- * "domain" attributes will have their values defaulted from @origin.
+ * "domain" attributes will have their values defaulted from @msg.
  *
  * Return value: a #GSList of #SoupCookie<!-- -->s, which can be freed
  * with soup_cookies_free().

Modified: branches/gnome-2-24/libsoup/soup-cookie.h
==============================================================================
--- branches/gnome-2-24/libsoup/soup-cookie.h	(original)
+++ branches/gnome-2-24/libsoup/soup-cookie.h	Wed Oct  1 20:13:43 2008
@@ -48,7 +48,7 @@
 void        soup_cookie_set_secure              (SoupCookie  *cookie,
 						 gboolean     secure);
 void        soup_cookie_set_http_only           (SoupCookie  *cookie,
-						 gboolean     secure);
+						 gboolean     http_only);
 
 char       *soup_cookie_to_set_cookie_header    (SoupCookie  *cookie);
 char       *soup_cookie_to_cookie_header        (SoupCookie  *cookie);

Modified: branches/gnome-2-24/libsoup/soup-dns.c
==============================================================================
--- branches/gnome-2-24/libsoup/soup-dns.c	(original)
+++ branches/gnome-2-24/libsoup/soup-dns.c	Wed Oct  1 20:13:43 2008
@@ -490,7 +490,7 @@
 
 	entry = soup_dns_cache_entry_lookup (name);
 	if (!entry)
-		entry = soup_dns_cache_entry_new (name); // FIXME
+		entry = soup_dns_cache_entry_new (name); /* FIXME */
 	g_free (name);
 
 	lookup = g_slice_new0 (SoupDNSLookup);

Modified: branches/gnome-2-24/libsoup/soup-headers.c
==============================================================================
--- branches/gnome-2-24/libsoup/soup-headers.c	(original)
+++ branches/gnome-2-24/libsoup/soup-headers.c	Wed Oct  1 20:13:43 2008
@@ -648,14 +648,14 @@
  * soup_header_parse_param_list:
  * @header: a header value
  *
- * Parses a header which is a comma-delimited list of something like
- *
- *   token [ "=" ( token | quoted-string ) ]
+ * Parses a header which is a comma-delimited list of something like:
+ * <literal>token [ "=" ( token | quoted-string ) ]</literal>.
  *
  * Tokens that don't have an associated value will still be added to
  * the resulting hash table, but with a %NULL value.
  * 
- * Return value: a #GHashTable of list elements.
+ * Return value: a #GHashTable of list elements, which can be freed
+ * with soup_header_free_param_list().
  **/
 GHashTable *
 soup_header_parse_param_list (const char *header)
@@ -668,14 +668,13 @@
  * @header: a header value
  *
  * Parses a header which is a semicolon-delimited list of something
- * like
- *
- *   token [ "=" ( token | quoted-string ) ]
+ * like: <literal>token [ "=" ( token | quoted-string ) ]</literal>.
  *
  * Tokens that don't have an associated value will still be added to
  * the resulting hash table, but with a %NULL value.
  * 
- * Return value: a #GHashTable of list elements.
+ * Return value: a #GHashTable of list elements, which can be freed
+ * with soup_header_free_param_list().
  **/
 GHashTable *
 soup_header_parse_semi_param_list (const char *header)
@@ -686,6 +685,7 @@
 /**
  * soup_header_free_param_list:
  * @param_list: a #GHashTable returned from soup_header_parse_param_list()
+ * or soup_header_parse_semi_param_list()
  *
  * Frees @param_list.
  **/

Modified: branches/gnome-2-24/libsoup/soup-logger.c
==============================================================================
--- branches/gnome-2-24/libsoup/soup-logger.c	(original)
+++ branches/gnome-2-24/libsoup/soup-logger.c	Wed Oct  1 20:13:43 2008
@@ -32,7 +32,7 @@
  * optionally configure it with soup_logger_set_request_filter(),
  * soup_logger_set_response_filter(), and soup_logger_set_printer(),
  * and then attach it to a session (or multiple sessions) with
- * soup_logger_attach().
+ * soup_session_add_feature().
  *
  * By default, the debugging output is sent to %stdout, and looks
  * something like:
@@ -79,7 +79,7 @@
 
 G_DEFINE_TYPE_WITH_CODE (SoupLogger, soup_logger, G_TYPE_OBJECT,
 			 G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
-						soup_logger_session_feature_init));
+						soup_logger_session_feature_init))
 
 typedef struct {
 	/* We use a mutex so that if requests are being run in

Modified: branches/gnome-2-24/libsoup/soup-message-body.h
==============================================================================
--- branches/gnome-2-24/libsoup/soup-message-body.h	(original)
+++ branches/gnome-2-24/libsoup/soup-message-body.h	Wed Oct  1 20:13:43 2008
@@ -14,7 +14,7 @@
 	SOUP_MEMORY_STATIC,
 	SOUP_MEMORY_TAKE,
 	SOUP_MEMORY_COPY,
-	SOUP_MEMORY_TEMPORARY,
+	SOUP_MEMORY_TEMPORARY
 } SoupMemoryUse;
 
 typedef struct {

Modified: branches/gnome-2-24/libsoup/soup-message.h
==============================================================================
--- branches/gnome-2-24/libsoup/soup-message.h	(original)
+++ branches/gnome-2-24/libsoup/soup-message.h	Wed Oct  1 20:13:43 2008
@@ -100,10 +100,10 @@
 						   SoupURI           *uri);
 
 typedef enum {
-	SOUP_MESSAGE_NO_REDIRECT      = (1 << 1),
 #ifndef LIBSOUP_DISABLE_DEPRECATED
 	SOUP_MESSAGE_OVERWRITE_CHUNKS = (1 << 3),
 #endif
+	SOUP_MESSAGE_NO_REDIRECT      = (1 << 1)
 } SoupMessageFlags;
 
 void           soup_message_set_flags           (SoupMessage        *msg,

Modified: branches/gnome-2-24/libsoup/soup-misc.h
==============================================================================
--- branches/gnome-2-24/libsoup/soup-misc.h	(original)
+++ branches/gnome-2-24/libsoup/soup-misc.h	Wed Oct  1 20:13:43 2008
@@ -44,7 +44,7 @@
 typedef enum {
 	SOUP_SSL_ERROR_HANDSHAKE_NEEDS_READ,
 	SOUP_SSL_ERROR_HANDSHAKE_NEEDS_WRITE,
-	SOUP_SSL_ERROR_CERTIFICATE,
+	SOUP_SSL_ERROR_CERTIFICATE
 } SoupSSLError;
 
 G_END_DECLS

Modified: branches/gnome-2-24/libsoup/soup-session-async.c
==============================================================================
--- branches/gnome-2-24/libsoup/soup-session-async.c	(original)
+++ branches/gnome-2-24/libsoup/soup-session-async.c	Wed Oct  1 20:13:43 2008
@@ -24,7 +24,7 @@
  **/
 
 static gboolean run_queue (SoupSessionAsync *sa);
-static void do_idle_run_queue (SoupSession *session);
+static void do_idle_run_queue (SoupSessionAsync *sa);
 
 static void  queue_message   (SoupSession *session, SoupMessage *req,
 			      SoupSessionCallback callback, gpointer user_data);
@@ -32,19 +32,41 @@
 
 G_DEFINE_TYPE (SoupSessionAsync, soup_session_async, SOUP_TYPE_SESSION)
 
+typedef struct {
+	GSource *idle_run_queue_source;
+} SoupSessionAsyncPrivate;
+#define SOUP_SESSION_ASYNC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_SESSION_ASYNC, SoupSessionAsyncPrivate))
+
 static void
 soup_session_async_init (SoupSessionAsync *sa)
 {
 }
 
 static void
+finalize (GObject *object)
+{
+	SoupSessionAsyncPrivate *priv = SOUP_SESSION_ASYNC_GET_PRIVATE (object);
+
+	if (priv->idle_run_queue_source)
+		g_source_destroy (priv->idle_run_queue_source);
+
+	G_OBJECT_CLASS (soup_session_async_parent_class)->finalize (object);
+}
+
+static void
 soup_session_async_class_init (SoupSessionAsyncClass *soup_session_async_class)
 {
 	SoupSessionClass *session_class = SOUP_SESSION_CLASS (soup_session_async_class);
+	GObjectClass *object_class = G_OBJECT_CLASS (session_class);
+
+	g_type_class_add_private (soup_session_async_class,
+				  sizeof (SoupSessionAsyncPrivate));
 
 	/* virtual method override */
 	session_class->queue_message = queue_message;
 	session_class->send_message = send_message;
+
+	object_class->finalize = finalize;
 }
 
 
@@ -86,12 +108,12 @@
 
 
 static void
-connection_closed (SoupConnection *conn, gpointer session)
+connection_closed (SoupConnection *conn, gpointer sa)
 {
 	/* Run the queue in case anyone was waiting for a connection
 	 * to be closed.
 	 */
-	do_idle_run_queue (session);
+	do_idle_run_queue (sa);
 }
 
 static void
@@ -99,34 +121,29 @@
 {
 	SoupSessionAsync *sa = user_data;
 
-	if (status != SOUP_STATUS_OK) {
-		/* The connection attempt failed, and thus @conn was
-		 * closed and the open connection count for the
-		 * session has been decremented. (If the failure was
-		 * fatal, then SoupSession itself will have dealt
-		 * with cancelling any pending messages for that
-		 * host, so we don't need to worry about that here.)
-		 * However, there may be other messages in the
-		 * queue that were waiting for the connection count
-		 * to go down, so run the queue now.
+	if (status == SOUP_STATUS_OK) {
+		g_signal_connect (conn, "disconnected",
+				  G_CALLBACK (connection_closed), sa);
+
+		/* @conn has been marked reserved by SoupSession, but
+		 * we don't actually have any specific message in mind
+		 * for it. (In particular, the message we were
+		 * originally planning to queue on it may have already
+		 * been queued on some other connection that became
+		 * available while we were waiting for this one to
+		 * connect.) So we release the connection into the
+		 * idle pool and then just run the queue and see what
+		 * happens.
 		 */
-		run_queue (sa);
-		return;
+		soup_connection_release (conn);
 	}
 
-	g_signal_connect (conn, "disconnected",
-			  G_CALLBACK (connection_closed), sa);
-
-	/* @conn has been marked reserved by SoupSession, but we don't
-	 * actually have any specific message in mind for it. (In
-	 * particular, the message we were originally planning to
-	 * queue on it may have already been queued on some other
-	 * connection that became available while we were waiting for
-	 * this one to connect.) So we release the connection into the
-	 * idle pool and then just run the queue and see what happens.
+	/* Even if the connection failed, we run the queue, since
+	 * there may have been messages waiting for the connection
+	 * count to go down.
 	 */
-	soup_connection_release (conn);
-	run_queue (sa);
+	do_idle_run_queue (sa);
+	g_object_unref (sa);
 }
 
 static gboolean
@@ -158,7 +175,7 @@
 
 		if (is_new) {
 			soup_connection_connect_async (conn, got_connection,
-						       session);
+						       g_object_ref (session));
 		} else
 			soup_connection_send_request (conn, msg);
 	}
@@ -195,46 +212,42 @@
 	SoupSessionAsyncQueueData *saqd = user_data;
 	SoupSessionAsync *sa = saqd->sa;
 
-	g_object_add_weak_pointer (G_OBJECT (sa), (gpointer)&sa);
-
+	g_object_ref (sa);
 	if (!SOUP_MESSAGE_IS_STARTING (req)) {
 		g_signal_handlers_disconnect_by_func (req, final_finished, saqd);
 		if (saqd->callback) {
 			saqd->callback ((SoupSession *)sa, req,
 					saqd->callback_data);
-			/* callback might destroy sa */
 		}
 
 		g_object_unref (req);
 		g_slice_free (SoupSessionAsyncQueueData, saqd);
 	}
 
-	if (sa) {
-		g_object_remove_weak_pointer (G_OBJECT (sa), (gpointer)&sa);
-		run_queue (sa);
-	}
+	do_idle_run_queue (sa);
+	g_object_unref (sa);
 }
 
 static gboolean
-idle_run_queue (gpointer user_data)
+idle_run_queue (gpointer sa)
 {
-	SoupSessionAsync *sa = user_data;
+	SoupSessionAsyncPrivate *priv = SOUP_SESSION_ASYNC_GET_PRIVATE (sa);
 
-	g_object_add_weak_pointer (G_OBJECT (sa), (gpointer)&sa);
-	g_object_unref (sa);
-
-	if (sa) {
-		g_object_remove_weak_pointer (G_OBJECT (sa), (gpointer)&sa);
-		run_queue (sa);
-	}
+	priv->idle_run_queue_source = NULL;
+	run_queue (sa);
 	return FALSE;
 }
 
 static void
-do_idle_run_queue (SoupSession *session)
+do_idle_run_queue (SoupSessionAsync *sa)
 {
-	soup_add_completion (soup_session_get_async_context (session),
-			     idle_run_queue, g_object_ref (session));
+	SoupSessionAsyncPrivate *priv = SOUP_SESSION_ASYNC_GET_PRIVATE (sa);
+
+	if (!priv->idle_run_queue_source) {
+		priv->idle_run_queue_source = soup_add_completion (
+			soup_session_get_async_context ((SoupSession *)sa),
+			idle_run_queue, sa);
+	}
 }
 
 static void
@@ -255,7 +268,7 @@
 				G_CALLBACK (final_finished), saqd);
 
 	SOUP_SESSION_CLASS (soup_session_async_parent_class)->queue_message (session, req, callback, user_data);
-	do_idle_run_queue (session);
+	do_idle_run_queue (sa);
 }
 
 static guint

Modified: branches/gnome-2-24/libsoup/soup-session-feature.c
==============================================================================
--- branches/gnome-2-24/libsoup/soup-session-feature.c	(original)
+++ branches/gnome-2-24/libsoup/soup-session-feature.c	Wed Oct  1 20:13:43 2008
@@ -11,6 +11,26 @@
 
 #include "soup-session-feature.h"
 
+/**
+ * SECTION:soup-session-feature
+ * @short_description: Interface for miscellaneous session features
+ *
+ * #SoupSessionFeature is the interface used by classes that extend
+ * the functionality of a #SoupSession. Some features like HTTP
+ * authentication handling are implemented internally via
+ * #SoupSessionFeature<!-- -->s. Other features can be added to the session
+ * by the application. (Eg, #SoupLogger, #SoupCookieJar.)
+ *
+ * See soup_session_add_feature(), etc, to add a feature to a session.
+ **/
+
+/**
+ * SoupSessionFeature:
+ *
+ * The interface implemented by objects that implement features for
+ * #SoupSession.
+ **/
+
 static void soup_session_feature_interface_init (SoupSessionFeatureInterface *interface);
 
 static void attach (SoupSessionFeature *feature, SoupSession *session);
@@ -93,13 +113,6 @@
 	}
 }
 
-/**
- * soup_session_feature_attach:
- * @feature: a #SoupSessionFeature
- * @session: a #SoupSession
- *
- * Adds @feature to @session.
- **/
 void
 soup_session_feature_attach (SoupSessionFeature *feature,
 			     SoupSession        *session)
@@ -119,15 +132,6 @@
 	g_object_unref (feature);
 }
 
-/**
- * soup_session_feature_detach:
- * @feature: a #SoupSessionFeature
- * @session: a #SoupSession
- *
- * Removes @feature from @session.
- *
- * Return value: success or failure
- **/
 void
 soup_session_feature_detach (SoupSessionFeature *feature,
 			     SoupSession        *session)

Modified: branches/gnome-2-24/libsoup/soup-session-feature.h
==============================================================================
--- branches/gnome-2-24/libsoup/soup-session-feature.h	(original)
+++ branches/gnome-2-24/libsoup/soup-session-feature.h	Wed Oct  1 20:13:43 2008
@@ -17,6 +17,9 @@
 #define SOUP_IS_SESSION_FEATURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SOUP_TYPE_SESSION_FEATURE))
 #define SOUP_SESSION_FEATURE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), SOUP_TYPE_SESSION_FEATURE, SoupSessionFeatureInterface))
 
+/* dummy struct for gtk-doc */
+struct _SoupSessionFeature {};
+
 typedef struct {
 	GTypeInterface parent;
 

Modified: branches/gnome-2-24/libsoup/soup-session.c
==============================================================================
--- branches/gnome-2-24/libsoup/soup-session.c	(original)
+++ branches/gnome-2-24/libsoup/soup-session.c	Wed Oct  1 20:13:43 2008
@@ -960,6 +960,7 @@
 	 * any messages waiting for this host, since they're out
 	 * of luck.
 	 */
+	g_object_ref (session);
 	for (msg = soup_message_queue_first (priv->queue, &iter); msg; msg = soup_message_queue_next (priv->queue, &iter)) {
 		if (get_host_for_message (session, msg) == host) {
 			if (status == SOUP_STATUS_TRY_AGAIN) {
@@ -971,6 +972,7 @@
 			}
 		}
 	}
+	g_object_unref (session);
 }
 
 /**
@@ -1338,6 +1340,15 @@
 	g_slist_free (conns);
 }
 
+/**
+ * soup_session_add_feature:
+ * @session: a #SoupSession
+ * @feature: an object that implements #SoupSessionFeature
+ *
+ * Adds @feature's functionality to @session. You can also add a
+ * feature to the session at construct time by using the
+ * %SOUP_SESSION_ADD_FEATURE property.
+ **/
 void
 soup_session_add_feature (SoupSession *session, SoupSessionFeature *feature)
 {
@@ -1351,6 +1362,17 @@
 	soup_session_feature_attach (feature, session);
 }
 
+/**
+ * soup_session_add_feature_by_type:
+ * @session: a #SoupSession
+ * @feature_type: the #GType of a class that implements #SoupSessionFeature
+ *
+ * Creates a new feature of type @feature_type and adds it to
+ * @session. You can use this instead of soup_session_add_feature() in
+ * the case wher you don't need to customize the new feature in any
+ * way. You can also add a feature to the session at construct time by
+ * using the %SOUP_SESSION_ADD_FEATURE_BY_TYPE property.
+ **/
 void
 soup_session_add_feature_by_type (SoupSession *session, GType feature_type)
 {
@@ -1364,6 +1386,13 @@
 	g_object_unref (feature);
 }
 
+/**
+ * soup_session_remove_feature:
+ * @session: a #SoupSession
+ * @feature: a feature that has previously been added to @session
+ *
+ * Removes @feature's functionality from @session.
+ **/
 void
 soup_session_remove_feature (SoupSession *session, SoupSessionFeature *feature)
 {
@@ -1379,6 +1408,16 @@
 	}
 }
 
+/**
+ * soup_session_remove_feature_by_type:
+ * @session: a #SoupSession
+ * @feature_type: the #GType of a class that implements #SoupSessionFeature
+ *
+ * Removes all features of type @feature_type (or any subclass of
+ * @feature_type) from @session. You can also remove standard features
+ * from the session at construct time by using the
+ * %SOUP_SESSION_REMOVE_FEATURE_BY_TYPE property.
+ **/
 void
 soup_session_remove_feature_by_type (SoupSession *session, GType feature_type)
 {

Modified: branches/gnome-2-24/libsoup/soup-xmlrpc.c
==============================================================================
--- branches/gnome-2-24/libsoup/soup-xmlrpc.c	(original)
+++ branches/gnome-2-24/libsoup/soup-xmlrpc.c	Wed Oct  1 20:13:43 2008
@@ -506,6 +506,7 @@
 			content = xmlNodeGetContent (mname);
 			soup_value_hash_insert_value (hash, (char *)content, &mgval);
 			xmlFree (content);
+			g_value_unset (&mgval);
 		}
 		g_value_init (value, G_TYPE_HASH_TABLE);
 		g_value_take_boxed (value, hash);

Modified: branches/gnome-2-24/libsoup/soup-xmlrpc.h
==============================================================================
--- branches/gnome-2-24/libsoup/soup-xmlrpc.h	(original)
+++ branches/gnome-2-24/libsoup/soup-xmlrpc.h	Wed Oct  1 20:13:43 2008
@@ -75,7 +75,7 @@
 	SOUP_XMLRPC_FAULT_SERVER_ERROR_INTERNAL_XML_RPC_ERROR = -32603,
 	SOUP_XMLRPC_FAULT_APPLICATION_ERROR = -32500,
 	SOUP_XMLRPC_FAULT_SYSTEM_ERROR = -32400,
-	SOUP_XMLRPC_FAULT_TRANSPORT_ERROR = -32300,
+	SOUP_XMLRPC_FAULT_TRANSPORT_ERROR = -32300
 } SoupXMLRPCFault;
 
 G_END_DECLS

Modified: branches/gnome-2-24/tests/auth-test.c
==============================================================================
--- branches/gnome-2-24/tests/auth-test.c	(original)
+++ branches/gnome-2-24/tests/auth-test.c	Wed Oct  1 20:13:43 2008
@@ -503,8 +503,7 @@
 		errors++;
 	}
 
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 
 	g_object_unref (msg1);
 	g_object_unref (msg3);
@@ -537,8 +536,7 @@
 	g_main_loop_run (loop);
 	g_signal_handler_disconnect (session, auth_id);
 
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 
 	g_object_unref (msg1);
 
@@ -607,8 +605,7 @@
 
 		g_object_unref (msg);
 	}
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 
 	/* And now for some regression tests */
 	loop = g_main_loop_new (NULL, TRUE);
@@ -633,8 +630,7 @@
 	g_free (uri);
 
 	g_main_loop_run (loop);
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 
 	debug_printf (1, "\nTesting digest nonce expiration:\n");
 
@@ -726,8 +722,7 @@
 	do_digest_nonce_test (session, "Fourth", uri, FALSE, FALSE);
 	g_free (uri);
 
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 
 	/* Async auth */
 	do_async_auth_test (base_uri);

Modified: branches/gnome-2-24/tests/chunk-test.c
==============================================================================
--- branches/gnome-2-24/tests/chunk-test.c	(original)
+++ branches/gnome-2-24/tests/chunk-test.c	Wed Oct  1 20:13:43 2008
@@ -69,6 +69,7 @@
 	debug_printf (2, "  clearing chunk\n");
 	if (*buffer_ptr) {
 		(*buffer_ptr)->length = 0;
+		g_free ((char *)(*buffer_ptr)->data);
 		*buffer_ptr = NULL;
 	} else {
 		debug_printf (2, "  chunk is already clear!\n");
@@ -83,7 +84,7 @@
 static void
 make_put_chunk (SoupBuffer **buffer, const char *text)
 {
-	*buffer = soup_buffer_new_with_owner (text, strlen (text),
+	*buffer = soup_buffer_new_with_owner (g_strdup (text), strlen (text),
 					      buffer, clear_buffer_ptr);
 }
 
@@ -248,8 +249,7 @@
 	do_request_test (session, base_uri);
 	debug_printf (2, "\n\n");
 	do_response_test (session, base_uri);
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 }
 
 static void

Modified: branches/gnome-2-24/tests/context-test.c
==============================================================================
--- branches/gnome-2-24/tests/context-test.c	(original)
+++ branches/gnome-2-24/tests/context-test.c	Wed Oct  1 20:13:43 2008
@@ -194,8 +194,7 @@
 	}
 	g_object_unref (msg);
 
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 	g_free (uri);
 
 	g_cond_signal (test1_cond);
@@ -240,8 +239,7 @@
 	}
 	g_object_unref (msg);
 
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 	g_free (uri);
 
 	g_source_remove (idle);

Modified: branches/gnome-2-24/tests/continue-test.c
==============================================================================
--- branches/gnome-2-24/tests/continue-test.c	(original)
+++ branches/gnome-2-24/tests/continue-test.c	Wed Oct  1 20:13:43 2008
@@ -47,13 +47,13 @@
 	event (msg, side, #name);		\
 }
 
-EVENT_HANDLER (got_informational);
-EVENT_HANDLER (got_headers);
-EVENT_HANDLER (got_body);
-EVENT_HANDLER (wrote_informational);
-EVENT_HANDLER (wrote_headers);
-EVENT_HANDLER (wrote_body);
-EVENT_HANDLER (finished);
+EVENT_HANDLER (got_informational)
+EVENT_HANDLER (got_headers)
+EVENT_HANDLER (got_body)
+EVENT_HANDLER (wrote_informational)
+EVENT_HANDLER (wrote_headers)
+EVENT_HANDLER (wrote_body)
+EVENT_HANDLER (finished)
 
 static void
 do_message (const char *path, gboolean long_body,
@@ -109,8 +109,7 @@
 	events = NULL;
 	session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL);
 	soup_session_send_message (session, msg);
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 
 	va_start (ap, auth);
 	while ((expected_event = va_arg (ap, const char *))) {

Modified: branches/gnome-2-24/tests/libsoup.supp
==============================================================================
--- branches/gnome-2-24/tests/libsoup.supp	(original)
+++ branches/gnome-2-24/tests/libsoup.supp	Wed Oct  1 20:13:43 2008
@@ -241,6 +241,52 @@
    fun:g_type_register_static
 }
 {
+   glib/typereg14
+   Memcheck:Leak
+   fun:malloc
+   fun:g_malloc
+   fun:g_memdup
+   fun:type_node_any_new_W
+   fun:g_type_register_static
+}
+{
+   glib/typereg15
+   Memcheck:Leak
+   fun:realloc
+   fun:g_realloc
+   fun:type_set_qdata_W
+   fun:type_add_interface_Wm
+}
+{
+   glib/typereg16
+   Memcheck:Leak
+   fun:malloc
+   fun:g_malloc
+   fun:g_memdup
+   fun:type_node_any_new_W
+   fun:type_node_new_W
+   fun:g_type_register_static
+}
+{
+   glib/typereg17
+   Memcheck:Leak
+   fun:malloc
+   fun:realloc
+   fun:g_realloc
+   fun:type_set_qdata_W
+   fun:type_add_flags_W
+   fun:g_type_register_static
+}
+{
+   glib/typereg18
+   Memcheck:Leak
+   fun:calloc
+   fun:g_malloc0
+   fun:type_set_qdata_W
+   fun:type_add_flags_W
+   fun:g_type_register_static
+}
+{
    glib/interface1
    Memcheck:Leak
    fun:calloc
@@ -276,6 +322,15 @@
    fun:g_type_add_interface_static
 }
 {
+   glib/interface5
+   Memcheck:Leak
+   fun:malloc
+   fun:realloc
+   fun:g_realloc
+   fun:type_iface_add_prerequisite_W
+   fun:g_type_interface_add_prerequisite
+}
+{
    glib/paramspec1
    Memcheck:Leak
    fun:malloc
@@ -471,7 +526,6 @@
    fun:g_malloc0
    fun:type_iface_ensure_dflt_vtable_Wm
    fun:type_iface_vtable_base_init_Wm
-   fun:g_type_class_ref
 }
 {
    glib/typeref8
@@ -480,7 +534,6 @@
    fun:g_malloc
    fun:g_memdup
    fun:type_iface_vtable_base_init_Wm
-   fun:g_type_class_ref
 }
 {
    glib/typeref9
@@ -601,6 +654,37 @@
    fun:g_thread_init
 }
 {
+   glib/langnames8
+   Memcheck:Leak
+   fun:malloc
+   fun:g_malloc
+   fun:g_slice_alloc
+   fun:g_hash_table_new_full
+   fun:g_hash_table_new
+   fun:read_aliases
+   fun:unalias_lang
+   fun:g_get_language_names
+   fun:_g_utils_thread_init
+   fun:g_thread_init_glib
+   fun:g_thread_init
+}
+{
+   glib/langnames9
+   Memcheck:Leak
+   fun:calloc
+   fun:g_malloc0
+   fun:g_hash_table_resize
+   fun:g_hash_table_maybe_resize
+   fun:g_hash_table_insert_internal
+   fun:g_hash_table_insert
+   fun:read_aliases
+   fun:unalias_lang
+   fun:g_get_language_names
+   fun:_g_utils_thread_init
+   fun:g_thread_init_glib
+   fun:g_thread_init
+}
+{
    glib/charsets
    Memcheck:Leak
    fun:malloc
@@ -796,6 +880,7 @@
    fun:calloc
    fun:g_malloc0
    fun:g_hash_table_new_full
+   fun:g_hash_table_new
    fun:g_data_initialize
 }
 {
@@ -878,7 +963,6 @@
    Memcheck:Leak
    fun:malloc
    fun:xmlNewRMutex
-   obj:/usr/lib/libxml2.so.2.6.31
    fun:xmlDictCreate
    fun:xmlInitParserCtxt
 }
@@ -931,14 +1015,12 @@
    gnutls/init6
    Memcheck:Leak
    fun:malloc
+   fun:do_malloc
    fun:_gcry_malloc
-   fun:gcry_malloc
-   fun:gcry_xmalloc
-   fun:gcry_xcalloc
+   fun:_gcry_xmalloc
+   fun:_gcry_xcalloc
    fun:initialize
-   fun:gcry_randomize
-   fun:gc_pseudo_random
-   fun:gnutls_global_init
+   fun:_gcry_randomize
 }
 {
    gnutls/init7
@@ -954,14 +1036,11 @@
    Memcheck:Leak
    fun:malloc
    fun:_gcry_private_malloc
+   fun:do_malloc
    fun:_gcry_malloc
-   fun:gcry_malloc
    fun:_gcry_module_add
    fun:gcry_cipher_register_default
    fun:_gcry_cipher_init
-   fun:global_init
-   fun:gcry_check_version
-   fun:gnutls_global_init
 }
 {
    gnutls/init9
@@ -989,8 +1068,6 @@
    fun:gcry_pthread_mutex_init
    fun:_gcry_ath_init
    fun:global_init
-   fun:gcry_check_version
-   fun:gnutls_global_init
 }
 {
    gnutls/init12
@@ -999,8 +1076,6 @@
    fun:gcry_pthread_mutex_init
    fun:mutex_init
    fun:initialize_basics
-   fun:gcry_control
-   fun:gnutls_global_init
 }
 {
    gnutls/init13
@@ -1012,6 +1087,30 @@
    fun:gcry_control
    fun:gnutls_global_init
 }
+{
+   gnutls/deflate
+   Memcheck:Cond
+   fun:longest_match
+   fun:deflate_fast
+   fun:deflate
+   fun:_gnutls_compress
+   fun:_gnutls_m_plaintext2compressed
+   fun:_gnutls_encrypt
+   fun:_gnutls_send_int
+   fun:gnutls_record_send
+}
+{
+   gnutls/handshake
+   Memcheck:Leak
+   fun:malloc
+   fun:_gnutls_mpi_dprint_lz
+   fun:_gnutls_dh_set_peer_public
+   fun:_gnutls_proc_dh_common_server_kx
+   fun:proc_dhe_server_kx
+   fun:_gnutls_recv_server_kx_message
+   fun:_gnutls_handshake_client
+   fun:gnutls_handshake
+}
 
 {
    libsoup/headers

Modified: branches/gnome-2-24/tests/misc-test.c
==============================================================================
--- branches/gnome-2-24/tests/misc-test.c	(original)
+++ branches/gnome-2-24/tests/misc-test.c	Wed Oct  1 20:13:43 2008
@@ -46,8 +46,8 @@
 
 /* Host header handling: client must be able to override the default
  * value, server must be able to recognize different Host values.
+ * #539803.
  */
-
 static void
 do_host_test (void)
 {
@@ -65,8 +65,7 @@
 	soup_session_send_message (session, one);
 	soup_session_send_message (session, two);
 
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 
 	if (!SOUP_STATUS_IS_SUCCESSFUL (one->status_code)) {
 		debug_printf (1, "  Message 1 failed: %d %s\n",
@@ -91,6 +90,97 @@
 	g_object_unref (two);
 }
 
+/* Dropping the application's ref on the session from a callback
+ * should not cause the session to be freed at an incorrect time.
+ * (This test will crash if it fails.) #533473
+ */
+static void
+cu_one_completed (SoupSession *session, SoupMessage *msg, gpointer loop)
+{
+	debug_printf (2, "  Message 1 completed\n");
+	if (msg->status_code != SOUP_STATUS_CANT_CONNECT) {
+		debug_printf (1, "  Unexpected status on Message 1: %d %s\n",
+			      msg->status_code, msg->reason_phrase);
+		errors++;
+	}
+	g_object_unref (session);
+}
+
+static gboolean
+cu_idle_quit (gpointer loop)
+{
+	g_main_loop_quit (loop);
+	return FALSE;
+}
+
+static void
+cu_two_completed (SoupSession *session, SoupMessage *msg, gpointer loop)
+{
+	debug_printf (2, "  Message 2 completed\n");
+	if (msg->status_code != SOUP_STATUS_CANT_CONNECT) {
+		debug_printf (1, "  Unexpected status on Message 2: %d %s\n",
+			      msg->status_code, msg->reason_phrase);
+		errors++;
+	}
+	g_idle_add (cu_idle_quit, loop); 
+}
+
+static void
+do_callback_unref_test (void)
+{
+	SoupServer *bad_server;
+	SoupSession *session;
+	SoupMessage *one, *two;
+	GMainLoop *loop;
+	char *bad_uri;
+
+	debug_printf (1, "Callback unref handling\n");
+
+	/* Get a guaranteed-bad URI */
+	bad_server = soup_server_new (NULL, NULL);
+	bad_uri = g_strdup_printf ("http://localhost:%u/";,
+				   soup_server_get_port (bad_server));
+	g_object_unref (bad_server);
+
+	session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL);
+	g_object_add_weak_pointer (G_OBJECT (session), (gpointer *)&session);
+
+	loop = g_main_loop_new (NULL, TRUE);
+
+	one = soup_message_new ("GET", bad_uri);
+	g_object_add_weak_pointer (G_OBJECT (one), (gpointer *)&one);
+	two = soup_message_new ("GET", bad_uri);
+	g_object_add_weak_pointer (G_OBJECT (two), (gpointer *)&two);
+	g_free (bad_uri);
+
+	soup_session_queue_message (session, one, cu_one_completed, loop);
+	soup_session_queue_message (session, two, cu_two_completed, loop);
+
+	g_main_loop_run (loop);
+	g_main_loop_unref (loop);
+
+	if (session) {
+		g_object_remove_weak_pointer (G_OBJECT (session), (gpointer *)&session);
+		debug_printf (1, "  Session not destroyed?\n");
+		errors++;
+		g_object_unref (session);
+	}
+	if (one) {
+		g_object_remove_weak_pointer (G_OBJECT (one), (gpointer *)&one);
+		debug_printf (1, "  Message 1 not destroyed?\n");
+		errors++;
+		g_object_unref (one);
+	}
+	if (two) {
+		g_object_remove_weak_pointer (G_OBJECT (two), (gpointer *)&two);
+		debug_printf (1, "  Message 2 not destroyed?\n");
+		errors++;
+		g_object_unref (two);
+	}
+
+	/* Otherwise, if we haven't crashed, we're ok. */
+}
+
 int
 main (int argc, char **argv)
 {
@@ -104,6 +194,7 @@
 				    soup_server_get_port (server));
 
 	do_host_test ();
+	do_callback_unref_test ();
 
 	g_free (base_uri);
 

Modified: branches/gnome-2-24/tests/ntlm-test.c
==============================================================================
--- branches/gnome-2-24/tests/ntlm-test.c	(original)
+++ branches/gnome-2-24/tests/ntlm-test.c	Wed Oct  1 20:13:43 2008
@@ -33,7 +33,7 @@
 	NTLM_RECEIVED_REQUEST,
 	NTLM_SENT_CHALLENGE,
 	NTLM_AUTHENTICATED_ALICE,
-	NTLM_AUTHENTICATED_BOB,
+	NTLM_AUTHENTICATED_BOB
 } NTLMServerState;
 
 #define NTLM_REQUEST_START "TlRMTVNTUAABAAAA"
@@ -110,6 +110,7 @@
 			if (!strncmp (decoded, "alice:password", len) ||
 			    !strncmp (decoded, "bob:password", len))
 				auth_required = FALSE;
+			g_free (decoded);
 		}
 	}
 
@@ -385,8 +386,7 @@
 		    user != NULL ? SOUP_STATUS_OK :
 		    SOUP_STATUS_UNAUTHORIZED);
 
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 }
 
 static void

Modified: branches/gnome-2-24/tests/pull-api.c
==============================================================================
--- branches/gnome-2-24/tests/pull-api.c	(original)
+++ branches/gnome-2-24/tests/pull-api.c	Wed Oct  1 20:13:43 2008
@@ -41,8 +41,7 @@
 	correct_response = soup_message_body_flatten (msg->response_body);
 
 	g_object_unref (msg);
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 }
 
 /* Pull API version 1: fully-async. More like a "poke" API. Rather
@@ -508,8 +507,7 @@
 			     TRUE, SOUP_STATUS_UNAUTHORIZED);
 	do_fully_async_test (session, base_uri, "/Basic/realm2/",
 			     TRUE, SOUP_STATUS_OK);
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 
 	debug_printf (1, "\nFully async, slow requests\n");
 	session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL);
@@ -521,8 +519,7 @@
 			     FALSE, SOUP_STATUS_UNAUTHORIZED);
 	do_fully_async_test (session, base_uri, "/Basic/realm2/",
 			     FALSE, SOUP_STATUS_OK);
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 
 	debug_printf (1, "\nSynchronously async\n");
 	session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL);
@@ -534,9 +531,7 @@
 				     SOUP_STATUS_UNAUTHORIZED);
 	do_synchronously_async_test (session, base_uri, "/Basic/realm2/",
 				     SOUP_STATUS_OK);
-
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 
 	soup_buffer_free (correct_response);
 

Modified: branches/gnome-2-24/tests/redirect-test.c
==============================================================================
--- branches/gnome-2-24/tests/redirect-test.c	(original)
+++ branches/gnome-2-24/tests/redirect-test.c	Wed Oct  1 20:13:43 2008
@@ -189,15 +189,13 @@
 	debug_printf (1, "Async session\n");
 	for (n = 0; n < n_tests; n++)
 		do_test (session, base_uri, n);
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 
 	session = soup_test_session_new (SOUP_TYPE_SESSION_SYNC, NULL);
 	debug_printf (1, "Sync session\n");
 	for (n = 0; n < n_tests; n++)
 		do_test (session, base_uri, n);
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 }
 
 static void

Modified: branches/gnome-2-24/tests/test-utils.c
==============================================================================
--- branches/gnome-2-24/tests/test-utils.c	(original)
+++ branches/gnome-2-24/tests/test-utils.c	Wed Oct  1 20:13:43 2008
@@ -100,14 +100,6 @@
 void
 test_cleanup (void)
 {
-	debug_printf (1, "\n");
-	if (errors) {
-		printf ("%s: %d error(s).%s\n",
-			g_get_prgname (), errors,
-			debug_level == 0 ? " Run with '-d' for details" : "");
-	} else
-		printf ("%s: OK\n", g_get_prgname ());
-
 #ifdef HAVE_APACHE
 	if (apache_running)
 		apache_cleanup ();
@@ -119,6 +111,14 @@
 		g_object_unref (logger);
 
 	g_main_context_unref (g_main_context_default ());
+
+	debug_printf (1, "\n");
+	if (errors) {
+		printf ("%s: %d error(s).%s\n",
+			g_get_prgname (), errors,
+			debug_level == 0 ? " Run with '-d' for details" : "");
+	} else
+		printf ("%s: OK\n", g_get_prgname ());
 }
 
 void
@@ -225,6 +225,21 @@
 	return session;
 }
 
+void
+soup_test_session_abort_unref (SoupSession *session)
+{
+	g_object_add_weak_pointer (G_OBJECT (session), (gpointer *)&session);
+
+	soup_session_abort (session);
+	g_object_unref (session);
+
+	if (session) {
+		errors++;
+		debug_printf (1, "leaked SoupSession!\n");
+		g_object_remove_weak_pointer (G_OBJECT (session), (gpointer *)&session);
+	}
+}
+
 static gpointer run_server_thread (gpointer user_data);
 
 SoupServer *
@@ -271,6 +286,9 @@
 static void
 test_server_shutdown (void)
 {
+	g_object_add_weak_pointer (G_OBJECT (test_server),
+				   (gpointer *)&test_server);
+
 	if (server_thread) {
 		soup_add_completion (soup_server_get_async_context (test_server),
 				     idle_quit_server, test_server);
@@ -278,6 +296,11 @@
 	} else
 		soup_server_quit (test_server);
 	g_object_unref (test_server);
-}
-
 
+	if (test_server) {
+		errors++;
+		debug_printf (1, "leaked SoupServer!\n");
+		g_object_remove_weak_pointer (G_OBJECT (test_server),
+					      (gpointer *)&test_server);
+	}
+}

Modified: branches/gnome-2-24/tests/test-utils.h
==============================================================================
--- branches/gnome-2-24/tests/test-utils.h	(original)
+++ branches/gnome-2-24/tests/test-utils.h	Wed Oct  1 20:13:43 2008
@@ -15,5 +15,7 @@
 void apache_cleanup (void);
 #endif
 
-SoupSession *soup_test_session_new (GType type, ...);
+SoupSession *soup_test_session_new         (GType type, ...);
+void         soup_test_session_abort_unref (SoupSession *session);
+
 SoupServer  *soup_test_server_new  (gboolean in_own_thread);

Modified: branches/gnome-2-24/tests/xmlrpc-test.c
==============================================================================
--- branches/gnome-2-24/tests/xmlrpc-test.c	(original)
+++ branches/gnome-2-24/tests/xmlrpc-test.c	Wed Oct  1 20:13:43 2008
@@ -468,8 +468,7 @@
 	if (!test_fault_args ())
 		errors++;
 
-	soup_session_abort (session);
-	g_object_unref (session);
+	soup_test_session_abort_unref (session);
 
 	test_cleanup ();
 	return errors != 0;



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