[evolution-mapi/gnome-3-4] Could leave EBookBackend local cache locked for updates



commit 235f057bb1669185c6e0e41f5a67f98f5d4d5af2
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jul 17 12:34:05 2012 +0200

    Could leave EBookBackend local cache locked for updates

 src/addressbook/e-book-backend-mapi-contacts.c |    4 ++--
 src/addressbook/e-book-backend-mapi-gal.c      |    2 +-
 src/addressbook/e-book-backend-mapi.c          |   14 ++++++++++----
 src/addressbook/e-book-backend-mapi.h          |    2 +-
 4 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-mapi-contacts.c b/src/addressbook/e-book-backend-mapi-contacts.c
index 0fa79a8..e2b83f6 100644
--- a/src/addressbook/e-book-backend-mapi-contacts.c
+++ b/src/addressbook/e-book-backend-mapi-contacts.c
@@ -148,7 +148,7 @@ transfer_contact_cb (EMapiConnection *conn,
 
 	tc->contact = e_mapi_book_utils_contact_from_object (conn, object, e_book_backend_mapi_get_book_uri (tc->ebma));
 	if (tc->contact)
-		return e_book_backend_mapi_notify_contact_update (tc->ebma, NULL, tc->contact, obj_index, obj_total, NULL);
+		return e_book_backend_mapi_notify_contact_update (tc->ebma, NULL, tc->contact, obj_index, obj_total, FALSE, NULL);
 
 	return TRUE;
 }
@@ -207,7 +207,7 @@ transfer_contacts_cb (EMapiConnection *conn,
 		if (tcd->cards)
 			*tcd->cards = g_slist_prepend (*tcd->cards, e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30));
 
-		if (!e_book_backend_mapi_notify_contact_update (tcd->ebma, tcd->book_view, contact, obj_index, obj_total, tcd->notify_contact_data)) {
+		if (!e_book_backend_mapi_notify_contact_update (tcd->ebma, tcd->book_view, contact, obj_index, obj_total, FALSE, tcd->notify_contact_data)) {
 			g_object_unref (contact);
 			return FALSE;
 		}
diff --git a/src/addressbook/e-book-backend-mapi-gal.c b/src/addressbook/e-book-backend-mapi-gal.c
index b4711cb..7734170 100644
--- a/src/addressbook/e-book-backend-mapi-gal.c
+++ b/src/addressbook/e-book-backend-mapi-gal.c
@@ -87,7 +87,7 @@ transfer_gal_cb (EMapiConnection *conn,
 		return TRUE;
 	}
 
-	if (!e_book_backend_mapi_notify_contact_update (tg->ebma, tg->book_view, contact, obj_index, obj_total, tg->notify_contact_data)) {
+	if (!e_book_backend_mapi_notify_contact_update (tg->ebma, tg->book_view, contact, obj_index, obj_total, FALSE, tg->notify_contact_data)) {
 		g_object_unref (contact);
 		return FALSE;
 	}
diff --git a/src/addressbook/e-book-backend-mapi.c b/src/addressbook/e-book-backend-mapi.c
index 2fb8378..1847564 100644
--- a/src/addressbook/e-book-backend-mapi.c
+++ b/src/addressbook/e-book-backend-mapi.c
@@ -871,7 +871,7 @@ ebbm_operation_cb (OperationBase *op, gboolean cancelled, EBookBackend *backend)
 				e_book_backend_sqlitedb_lock_updates (ebma->priv->db, NULL);
 
 				for (l = added_contacts; l; l = l->next) {
-					e_book_backend_mapi_notify_contact_update (ebma, NULL, E_CONTACT (l->data), -1, -1, NULL);
+					e_book_backend_mapi_notify_contact_update (ebma, NULL, E_CONTACT (l->data), -1, -1, TRUE, NULL);
 				}
 
 				e_book_backend_sqlitedb_unlock_updates (ebma->priv->db, TRUE, NULL);
@@ -935,7 +935,7 @@ ebbm_operation_cb (OperationBase *op, gboolean cancelled, EBookBackend *backend)
 				e_book_backend_sqlitedb_lock_updates (ebma->priv->db, NULL);
 
 				for (l = modified_contacts; l; l = l->next) {
-					e_book_backend_mapi_notify_contact_update (ebma, NULL, E_CONTACT (l->data), -1, -1, NULL);
+					e_book_backend_mapi_notify_contact_update (ebma, NULL, E_CONTACT (l->data), -1, -1, TRUE, NULL);
 				}
 
 				e_book_backend_sqlitedb_unlock_updates (ebma->priv->db, TRUE, NULL);
@@ -1530,7 +1530,13 @@ e_book_backend_mapi_update_view_by_cache (EBookBackendMAPI *ebma, EDataBookView
    notify_contact_data is a pointer to glong last_notification, if not NULL;
    returns whether can continue with fetching */
 gboolean
-e_book_backend_mapi_notify_contact_update (EBookBackendMAPI *ebma, EDataBookView *pbook_view, EContact *contact, gint index, gint total, gpointer notify_contact_data)
+e_book_backend_mapi_notify_contact_update (EBookBackendMAPI *ebma,
+					   EDataBookView *pbook_view,
+					   EContact *contact,
+					   gint index,
+					   gint total,
+					   gboolean cache_is_locked,
+					   gpointer notify_contact_data)
 {
 	EBookBackendMAPIPrivate *priv;
 	glong *last_notification = notify_contact_data;
@@ -1580,7 +1586,7 @@ e_book_backend_mapi_notify_contact_update (EBookBackendMAPI *ebma, EDataBookView
 					     FALSE, &error);
 
 	/* commit not often than each minute, also to not lose data already transferred */
-	if (current_time - priv->last_db_commit_time >= 60000) {
+	if (cache_is_locked && current_time - priv->last_db_commit_time >= 60000) {
 		e_book_backend_sqlitedb_unlock_updates (priv->db, TRUE, NULL);
 		e_book_backend_sqlitedb_lock_updates (priv->db, NULL);
 
diff --git a/src/addressbook/e-book-backend-mapi.h b/src/addressbook/e-book-backend-mapi.h
index 49abb27..9d0e9a7 100644
--- a/src/addressbook/e-book-backend-mapi.h
+++ b/src/addressbook/e-book-backend-mapi.h
@@ -108,7 +108,7 @@ void e_book_backend_mapi_get_db (EBookBackendMAPI *ebma, EBookBackendSqliteDB **
 gboolean e_book_backend_mapi_book_view_is_running (EBookBackendMAPI *ebma, EDataBookView *book_view);
 void e_book_backend_mapi_update_view_by_cache (EBookBackendMAPI *ebma, EDataBookView *book_view, GError **error);
 gboolean e_book_backend_mapi_is_marked_for_offline (EBookBackendMAPI *ebma);
-gboolean e_book_backend_mapi_notify_contact_update (EBookBackendMAPI *ebma, EDataBookView *book_view, EContact *contact, gint index, gint total, gpointer notify_contact_data);
+gboolean e_book_backend_mapi_notify_contact_update (EBookBackendMAPI *ebma, EDataBookView *book_view, EContact *contact, gint index, gint total, gboolean cache_is_locked, gpointer notify_contact_data);
 void e_book_backend_mapi_notify_contact_removed (EBookBackendMAPI *ebma, const gchar *uid);
 void   e_book_backend_mapi_cache_set (EBookBackendMAPI *ebma, const gchar *key, const gchar *value);
 gchar *e_book_backend_mapi_cache_get (EBookBackendMAPI *ebma, const gchar *key);



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