[evolution-exchange/gnome-3-0] Bug #634971 - Crash in update_cache() due to freed backend
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-exchange/gnome-3-0] Bug #634971 - Crash in update_cache() due to freed backend
- Date: Thu, 23 Jun 2011 11:15:09 +0000 (UTC)
commit 138e2a26b22efc4d0ce8a910391c0b8a83631a73
Author: Milan Crha <mcrha redhat com>
Date: Thu Jun 23 13:14:45 2011 +0200
Bug #634971 - Crash in update_cache() due to freed backend
addressbook/e-book-backend-exchange.c | 17 ++++++++++++-----
calendar/e-cal-backend-exchange-calendar.c | 14 +++++++++++---
calendar/e-cal-backend-exchange-tasks.c | 14 +++++++++++---
3 files changed, 34 insertions(+), 11 deletions(-)
---
diff --git a/addressbook/e-book-backend-exchange.c b/addressbook/e-book-backend-exchange.c
index 09682dd..2f76052 100644
--- a/addressbook/e-book-backend-exchange.c
+++ b/addressbook/e-book-backend-exchange.c
@@ -646,10 +646,13 @@ build_cache (EBookBackendExchange *be)
bepriv->is_cache_ready=TRUE;
e_file_cache_thaw_changes (E_FILE_CACHE (bepriv->cache));
UNLOCK (bepriv);
+
+ g_object_unref (be);
+
return NULL;
}
-static gboolean
+static gpointer
update_cache (EBookBackendExchange *be)
{
EBookBackendExchangePrivate *bepriv = be->priv;
@@ -678,7 +681,10 @@ update_cache (EBookBackendExchange *be)
bepriv->is_cache_ready=TRUE;
e_file_cache_thaw_changes (E_FILE_CACHE (bepriv->cache));
UNLOCK (bepriv);
- return TRUE;
+
+ g_object_unref (be);
+
+ return NULL;
}
static gboolean
@@ -2716,12 +2722,13 @@ e_book_backend_exchange_authenticate_user (EBookBackend *backend,
e_book_backend_exchange_connect (be, NULL);
if (e_book_backend_cache_is_populated (bepriv->cache)) {
if (bepriv->is_writable)
- g_thread_create ((GThreadFunc) update_cache,
- be, FALSE, NULL);
+ if (!g_thread_create ((GThreadFunc) update_cache, g_object_ref (be), FALSE, NULL))
+ g_object_unref (be);
}
else if (bepriv->is_writable || bepriv->marked_for_offline) {
/* for personal books we always cache*/
- g_thread_create ((GThreadFunc) build_cache, be, FALSE, NULL);
+ if (!g_thread_create ((GThreadFunc) build_cache, g_object_ref (be), FALSE, NULL))
+ g_object_unref (be);
}
e_data_book_respond_authenticate_user (book, opid, NULL);
return;
diff --git a/calendar/e-cal-backend-exchange-calendar.c b/calendar/e-cal-backend-exchange-calendar.c
index d557461..a143380 100644
--- a/calendar/e-cal-backend-exchange-calendar.c
+++ b/calendar/e-cal-backend-exchange-calendar.c
@@ -437,6 +437,7 @@ get_changed_events (ECalBackendExchange *cbex)
g_hash_table_destroy (modtimes);
g_hash_table_destroy (attachments);
g_mutex_unlock (cbexc->priv->mutex);
+ g_object_unref (cbexc);
return status;
}
@@ -452,6 +453,7 @@ get_changed_events (ECalBackendExchange *cbex)
g_hash_table_destroy (attachments);
cbexc->priv->is_loaded = TRUE;
g_mutex_unlock (cbexc->priv->mutex);
+ g_object_unref (cbexc);
return SOUP_STATUS_OK;
}
@@ -506,6 +508,7 @@ get_changed_events (ECalBackendExchange *cbex)
g_hash_table_destroy (modtimes);
g_hash_table_destroy (attachments);
g_mutex_unlock (cbexc->priv->mutex);
+ g_object_unref (cbexc);
return status;
}
if (!hrefs->len) {
@@ -514,6 +517,7 @@ get_changed_events (ECalBackendExchange *cbex)
g_hash_table_destroy (attachments);
cbexc->priv->is_loaded = TRUE;
g_mutex_unlock (cbexc->priv->mutex);
+ g_object_unref (cbexc);
return SOUP_STATUS_OK;
}
@@ -521,6 +525,7 @@ get_changed_events (ECalBackendExchange *cbex)
ctx = exchange_account_get_context (cbex->account);
if (!ctx) {
g_mutex_unlock (cbexc->priv->mutex);
+ g_object_unref (cbexc);
/* This either means we lost connection or we are in offline mode */
return SOUP_STATUS_CANT_CONNECT;
}
@@ -550,6 +555,8 @@ get_changed_events (ECalBackendExchange *cbex)
cbexc->priv->is_loaded = TRUE;
g_mutex_unlock (cbexc->priv->mutex);
+ g_object_unref (cbexc);
+
return status;
}
@@ -564,7 +571,7 @@ notify_changes (E2kContext *ctx, const gchar *uri,
g_return_if_fail (E_IS_CAL_BACKEND_EXCHANGE (ecalbex));
g_return_if_fail (uri != NULL);
- get_changed_events (ecalbex);
+ get_changed_events (g_object_ref (ecalbex));
}
@@ -603,11 +610,12 @@ open_calendar (ECalBackendSync *backend, EDataCal *cal,
E2K_CONTEXT_OBJECT_REMOVED, 30,
notify_changes, backend);
- thread = g_thread_create ((GThreadFunc) get_changed_events, E_CAL_BACKEND_EXCHANGE (backend), FALSE, &error);
+ thread = g_thread_create ((GThreadFunc) get_changed_events, g_object_ref (backend), FALSE, &error);
if (!thread) {
g_warning (G_STRLOC ": %s", error->message);
g_propagate_error (perror, EDC_ERROR_EX (OtherError, error->message));
g_error_free (error);
+ g_object_unref (backend);
}
}
@@ -616,7 +624,7 @@ refresh_calendar (ECalBackendSync *backend, EDataCal *cal, GError **perror)
{
g_return_if_fail (E_IS_CAL_BACKEND_EXCHANGE (backend));
- get_changed_events (E_CAL_BACKEND_EXCHANGE (backend));
+ get_changed_events (g_object_ref (backend));
}
struct _cb_data {
diff --git a/calendar/e-cal-backend-exchange-tasks.c b/calendar/e-cal-backend-exchange-tasks.c
index c38121c..054ac83 100644
--- a/calendar/e-cal-backend-exchange-tasks.c
+++ b/calendar/e-cal-backend-exchange-tasks.c
@@ -854,6 +854,7 @@ get_changed_tasks (ECalBackendExchange *cbex)
g_hash_table_destroy (modtimes);
g_hash_table_destroy (attachments);
g_mutex_unlock (cbext->priv->mutex);
+ g_object_unref (cbext);
return status;
}
@@ -868,6 +869,7 @@ get_changed_tasks (ECalBackendExchange *cbex)
g_hash_table_destroy (attachments);
cbext->priv->is_loaded = TRUE;
g_mutex_unlock (cbext->priv->mutex);
+ g_object_unref (cbext);
return SOUP_STATUS_OK;
}
@@ -913,6 +915,7 @@ get_changed_tasks (ECalBackendExchange *cbex)
g_ptr_array_free (hrefs, TRUE);
g_hash_table_destroy (attachments);
g_mutex_unlock (cbext->priv->mutex);
+ g_object_unref (cbext);
return status;
}
@@ -921,12 +924,14 @@ get_changed_tasks (ECalBackendExchange *cbex)
g_hash_table_destroy (attachments);
cbext->priv->is_loaded = TRUE;
g_mutex_unlock (cbext->priv->mutex);
+ g_object_unref (cbext);
return SOUP_STATUS_OK;
}
ctx = exchange_account_get_context (cbex->account);
if (!ctx) {
g_mutex_unlock (cbext->priv->mutex);
+ g_object_unref (cbext);
/* This either means we lost connection or we are in offline mode */
return SOUP_STATUS_CANT_CONNECT;
}
@@ -967,6 +972,8 @@ get_changed_tasks (ECalBackendExchange *cbex)
cbext->priv->is_loaded = TRUE;
g_mutex_unlock (cbext->priv->mutex);
+ g_object_unref (cbext);
+
return status;
}
@@ -981,7 +988,7 @@ notify_changes (E2kContext *ctx, const gchar *uri,
g_return_if_fail (E_IS_CAL_BACKEND_EXCHANGE (ecalbex));
g_return_if_fail (uri != NULL);
- get_changed_tasks (ecalbex);
+ get_changed_tasks (g_object_ref (ecalbex));
}
@@ -1020,10 +1027,11 @@ open_task (ECalBackendSync *backend, EDataCal *cal,
E2K_CONTEXT_OBJECT_REMOVED, 30,
notify_changes, backend);
- thread = g_thread_create ((GThreadFunc) get_changed_tasks, E_CAL_BACKEND_EXCHANGE (backend), FALSE, &error);
+ thread = g_thread_create ((GThreadFunc) get_changed_tasks, g_object_ref (backend), FALSE, &error);
if (!thread) {
g_propagate_error (perror, EDC_ERROR_EX (OtherError, error->message));
g_error_free (error);
+ g_object_unref (backend);
}
}
@@ -1032,7 +1040,7 @@ refresh_task (ECalBackendSync *backend, EDataCal *cal, GError **perror)
{
g_return_if_fail (E_IS_CAL_BACKEND_EXCHANGE (backend));
- get_changed_tasks (E_CAL_BACKEND_EXCHANGE (backend));
+ get_changed_tasks (g_object_ref (backend));
}
struct _cb_data {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]