[evolution-mapi] Could leave EBookBackend local cache locked for updates
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-mapi] Could leave EBookBackend local cache locked for updates
- Date: Tue, 17 Jul 2012 10:33:53 +0000 (UTC)
commit 390555c561b39a6c1bd978a23751c2a8db2b43d2
Author: Milan Crha <mcrha redhat com>
Date: Tue Jul 17 12:32:26 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 | 1 +
4 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-mapi-contacts.c b/src/addressbook/e-book-backend-mapi-contacts.c
index 795a146..2a31ac0 100644
--- a/src/addressbook/e-book-backend-mapi-contacts.c
+++ b/src/addressbook/e-book-backend-mapi-contacts.c
@@ -142,7 +142,7 @@ transfer_contact_cb (EMapiConnection *conn,
tc->contact = e_mapi_book_utils_contact_from_object (conn, object, e_book_backend_mapi_get_book_uid (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;
}
@@ -201,7 +201,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 cf1c7dd..c1b8166 100644
--- a/src/addressbook/e-book-backend-mapi-gal.c
+++ b/src/addressbook/e-book-backend-mapi-gal.c
@@ -84,7 +84,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 e3be67b..2957842 100644
--- a/src/addressbook/e-book-backend-mapi.c
+++ b/src/addressbook/e-book-backend-mapi.c
@@ -944,7 +944,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);
@@ -1008,7 +1008,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);
@@ -1572,7 +1572,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;
@@ -1622,7 +1628,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 358ed2a..f5d232b 100644
--- a/src/addressbook/e-book-backend-mapi.h
+++ b/src/addressbook/e-book-backend-mapi.h
@@ -121,6 +121,7 @@ gboolean e_book_backend_mapi_notify_contact_update (EBookBackendMAPI *ebma,
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]