evolution-data-server r9693 - in trunk/servers/exchange: . lib



Author: abharath
Date: Sun Oct 19 16:50:54 2008
New Revision: 9693
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9693&view=rev

Log:
2008-10-19  Milan Crha  <mcrha redhat com>

        ** Fix for bug #553944

         * lib/e2k-context.c: (unsubscribe_internal), (destroy_sub_list),
          (e2k_context_unsubscribe): Do not unsubscribe from the server when
          destroying context and make copy of the uri, because it comes from
          the structure we are going to free.


Modified:
   trunk/servers/exchange/ChangeLog
   trunk/servers/exchange/lib/e2k-context.c

Modified: trunk/servers/exchange/lib/e2k-context.c
==============================================================================
--- trunk/servers/exchange/lib/e2k-context.c	(original)
+++ trunk/servers/exchange/lib/e2k-context.c	Sun Oct 19 16:50:54 2008
@@ -125,7 +125,7 @@
 #endif
 
 static gboolean renew_subscription (gpointer user_data);
-static void unsubscribe_internal (E2kContext *ctx, const char *uri, GList *sub_list);
+static void unsubscribe_internal (E2kContext *ctx, const char *uri, GList *sub_list, gboolean destrying);
 static gboolean do_notification (GIOChannel *source, GIOCondition condition, gpointer data);
 
 static void setup_message (SoupSession *session, SoupMessage *msg, SoupSocket *socket, gpointer user_data);
@@ -173,7 +173,7 @@
 static void
 destroy_sub_list (gpointer uri, gpointer sub_list, gpointer ctx)
 {
-	unsubscribe_internal (ctx, uri, sub_list);
+	unsubscribe_internal (ctx, uri, sub_list, TRUE);
 	g_list_free (sub_list);
 }
 
@@ -2673,21 +2673,27 @@
 }
 
 static void
-unsubscribe_internal (E2kContext *ctx, const char *uri, GList *sub_list)
+unsubscribe_internal (E2kContext *ctx, const char *puri, GList *sub_list, gboolean destrying)
 {
 	GList *l;
 	E2kSubscription *sub;
 	SoupMessage *msg;
 	GString *subscription_ids = NULL;
+	char *uri = g_strdup (puri);
+	/* puri comes from sub->uri, but we are using it after sub is freed, thus making copy here */
 
 	for (l = sub_list; l; l = l->next) {
 		sub = l->data;
 		if (sub->id) {
-			if (!subscription_ids)
-				subscription_ids = g_string_new (sub->id);
-			else {
-				g_string_append_printf (subscription_ids,
+			/* do not send messages when destroying, because they are server on idle,
+			   when the context itself already gone */
+			if (!destrying) {
+				if (!subscription_ids)
+					subscription_ids = g_string_new (sub->id);
+				else {
+					g_string_append_printf (subscription_ids,
 							",%s", sub->id);
+				}
 			}
 			g_hash_table_remove (ctx->priv->subscriptions_by_id, sub->id);
 		}
@@ -2696,12 +2702,16 @@
 
 	if (subscription_ids) {
 		msg = e2k_soup_message_new (ctx, uri, "UNSUBSCRIBE");
-		soup_message_headers_append (msg->request_headers,
-					     "Subscription-id",
-					     subscription_ids->str);
-		e2k_context_queue_message (ctx, msg, unsubscribed, NULL);
+		if (msg) {
+			soup_message_headers_append (msg->request_headers,
+						     "Subscription-id",
+						     subscription_ids->str);
+			e2k_context_queue_message (ctx, msg, unsubscribed, NULL);
+		}
 		g_string_free (subscription_ids, TRUE);
 	}
+
+	g_free (uri);
 }
 
 /**
@@ -2720,6 +2730,6 @@
 
 	sub_list = g_hash_table_lookup (ctx->priv->subscriptions_by_uri, uri);
 	g_hash_table_remove (ctx->priv->subscriptions_by_uri, uri);
-	unsubscribe_internal (ctx, uri, sub_list);
+	unsubscribe_internal (ctx, uri, sub_list, FALSE);
 	g_list_free (sub_list);
 }



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