Blame SOURCES/evolution-data-server-3.8.5-caldav-initialize-backend-crash.patch

6bbc61
diff -up evolution-data-server-3.8.5/calendar/backends/caldav/e-cal-backend-caldav.c.caldav-initialize-backend-crash evolution-data-server-3.8.5/calendar/backends/caldav/e-cal-backend-caldav.c
6bbc61
--- evolution-data-server-3.8.5/calendar/backends/caldav/e-cal-backend-caldav.c.caldav-initialize-backend-crash	2014-01-15 15:01:59.631683627 +0100
6bbc61
+++ evolution-data-server-3.8.5/calendar/backends/caldav/e-cal-backend-caldav.c	2014-01-15 15:01:59.682683626 +0100
6bbc61
@@ -5071,20 +5071,23 @@ caldav_source_changed_thread (gpointer d
6bbc61
 
6bbc61
 	old_slave_cmd = cbdav->priv->slave_cmd;
6bbc61
 	old_slave_busy = cbdav->priv->slave_busy;
6bbc61
-	if (old_slave_busy) {
6bbc61
+	if (old_slave_busy)
6bbc61
 		update_slave_cmd (cbdav->priv, SLAVE_SHOULD_SLEEP);
6bbc61
-		g_mutex_lock (&cbdav->priv->busy_lock);
6bbc61
-	}
6bbc61
 
6bbc61
+	g_mutex_lock (&cbdav->priv->busy_lock);
6bbc61
+
6bbc61
+	/* guard the call with busy_lock, thus the two threads (this 'source changed'
6bbc61
+	   thread and the 'backend open' thread) will not clash on internal data
6bbc61
+	   when they are called in once */
6bbc61
 	initialize_backend (cbdav, NULL);
6bbc61
 
6bbc61
 	/* always wakeup thread, even when it was sleeping */
6bbc61
 	g_cond_signal (&cbdav->priv->cond);
6bbc61
 
6bbc61
-	if (old_slave_busy) {
6bbc61
+	if (old_slave_busy)
6bbc61
 		update_slave_cmd (cbdav->priv, old_slave_cmd);
6bbc61
-		g_mutex_unlock (&cbdav->priv->busy_lock);
6bbc61
-	}
6bbc61
+
6bbc61
+	g_mutex_unlock (&cbdav->priv->busy_lock);
6bbc61
 
6bbc61
 	cbdav->priv->updating_source = FALSE;
6bbc61
 
6bbc61
@@ -5102,7 +5105,9 @@ caldav_source_changed_cb (ESource *sourc
6bbc61
 	g_return_if_fail (source != NULL);
6bbc61
 	g_return_if_fail (cbdav != NULL);
6bbc61
 
6bbc61
-	if (cbdav->priv->updating_source)
6bbc61
+	if (cbdav->priv->updating_source ||
6bbc61
+	    !cbdav->priv->loaded ||
6bbc61
+	    !e_cal_backend_is_opened (E_CAL_BACKEND (cbdav)))
6bbc61
 		return;
6bbc61
 
6bbc61
 	cbdav->priv->updating_source = TRUE;