Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:pchenthill
evolution-data-server
eds-cpu-g_timeout-hibernate.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File eds-cpu-g_timeout-hibernate.patch of Package evolution-data-server
--- addressbook/backends/groupwise/e-book-backend-groupwise.c.orig 2007-04-20 00:04:14.000000000 +0530 +++ addressbook/backends/groupwise/e-book-backend-groupwise.c 2007-04-20 00:13:13.000000000 +0530 @@ -73,8 +73,7 @@ struct _EBookBackendGroupwisePrivate { int mode; int cache_timeout; EBookBackendSummary *summary; - GMutex *update_cache_mutex; - GMutex *update_mutex; + int update_atom; DB *file_db; DB_ENV *env; /* for future use */ @@ -91,6 +90,8 @@ static struct { #define ELEMENT_TYPE_COMPLEX 0x02 /* fields which require explicit functions to set values into EContact and EGwItem */ #define SUMMARY_FLUSH_TIMEOUT 5000 +#define d(x) + gboolean enable_debug = FALSE; static void populate_emails (EContact *contact, gpointer data); @@ -2785,7 +2786,10 @@ update_cache (EBookBackendGroupwise *ebg if (!ebgw) return FALSE; - g_mutex_lock (ebgw->priv->update_cache_mutex); + if (!g_atomic_int_compare_and_exchange (&ebgw->priv->update_atom, 0, 1)) { + d(g_print("%s:%s:%d: An updater thread is running already\n", __FILE__, __PRETTY_FUNCTION__, __LINE__)); + return TRUE; /* As another thread is already running, we return a TRUE as a sign of "not a failure" */ + } if (enable_debug) { g_get_current_time(&start); @@ -2825,7 +2829,7 @@ update_cache (EBookBackendGroupwise *ebg bonobo_object_unref (book_view); if (enable_debug) printf("No connection with the server \n"); - g_mutex_unlock (ebgw->priv->update_cache_mutex); + g_atomic_int_compare_and_exchange (&ebgw->priv->update_atom, 1, 0); return FALSE; } @@ -2880,7 +2884,7 @@ update_cache (EBookBackendGroupwise *ebg printf("updating the cache for %s complated in %ld.%03ld seconds for %d contacts\n", ebgw->priv->book_name, diff / 1000, diff % 1000, contact_num); } - g_mutex_unlock (ebgw->priv->update_cache_mutex); + g_atomic_int_compare_and_exchange (&ebgw->priv->update_atom, 1, 0); return FALSE; } @@ -2897,14 +2901,18 @@ update_address_book_deltas (EBookBackend EDataBookView *book_view; GroupwiseBackendSearchClosure *closure; EGwItem *item; + EBookBackendGroupwisePrivate *priv; if (!ebgw) return FALSE; - EBookBackendGroupwisePrivate *priv = ebgw->priv; - - g_mutex_lock (priv->update_mutex); + priv = ebgw->priv; + if (!g_atomic_int_compare_and_exchange (&priv->update_atom, 0, 1)) { + d(g_print("%s:%s:%d: An updater thread is running already\n", __FILE__, __PRETTY_FUNCTION__, __LINE__)); + return TRUE; /* As another thread is already running, we return a TRUE as a sign of "not a failure" */ + } + if (enable_debug) printf("\nupdating GroupWise system address book cache \n"); @@ -2917,7 +2925,7 @@ update_address_book_deltas (EBookBackend if (status != E_GW_CONNECTION_STATUS_OK) { if (enable_debug) printf("No connection with the server \n"); - g_mutex_unlock (priv->update_mutex); + g_atomic_int_compare_and_exchange (&priv->update_atom, 1, 0); return FALSE; } @@ -2930,7 +2938,7 @@ update_address_book_deltas (EBookBackend add_sequence_to_cache (priv->file_db, server_first_sequence, server_last_sequence, server_last_po_rebuild_time); ebgw->priv->file_db->sync (ebgw->priv->file_db, 0); - g_mutex_unlock (priv->update_mutex); + g_atomic_int_compare_and_exchange (&priv->update_atom, 1, 0); return TRUE; } @@ -2947,7 +2955,7 @@ update_address_book_deltas (EBookBackend add_sequence_to_cache (priv->file_db, server_first_sequence, server_last_sequence, server_last_po_rebuild_time); ebgw->priv->file_db->sync (ebgw->priv->file_db, 0); - g_mutex_unlock (priv->update_mutex); + g_atomic_int_compare_and_exchange (&priv->update_atom, 1, 0); return TRUE; } @@ -3002,7 +3010,7 @@ update_address_book_deltas (EBookBackend printf("sequence differs but no changes found !!!\n"); add_sequence_to_cache (priv->file_db, server_first_sequence, server_last_sequence, server_last_po_rebuild_time); - g_mutex_unlock (priv->update_mutex); + g_atomic_int_compare_and_exchange (&priv->update_atom, 1, 0); return TRUE; } sync_required = TRUE; @@ -3128,7 +3136,7 @@ update_address_book_deltas (EBookBackend printf("updating GroupWise system address book cache took %ld.%03ld seconds for %d changes\n", diff / 1000, diff % 1000, contact_num); } - g_mutex_unlock(priv->update_mutex); + g_atomic_int_compare_and_exchange (&priv->update_atom, 1, 0); return TRUE; } @@ -3756,11 +3764,6 @@ e_book_backend_groupwise_dispose (GObjec g_source_remove (bgw->priv->cache_timeout); bgw->priv->cache_timeout = 0; } - if (bgw->priv->update_mutex) - g_mutex_free (bgw->priv->update_mutex); - if (bgw->priv->update_cache_mutex) - g_mutex_free (bgw->priv->update_cache_mutex); - g_free (bgw->priv); bgw->priv = NULL; } @@ -3817,8 +3820,6 @@ e_book_backend_groupwise_init (EBookBack priv->cnc = NULL; priv->original_uri = NULL; priv->cache_timeout = 0; - priv->update_mutex = g_mutex_new(); - priv->update_cache_mutex = g_mutex_new (); priv->reserved1 = NULL; backend->priv = priv; --- calendar/backends/groupwise/e-cal-backend-groupwise.c.orig 2007-04-19 23:17:01.000000000 +0530 +++ calendar/backends/groupwise/e-cal-backend-groupwise.c 2007-04-20 00:13:32.000000000 +0530 @@ -93,6 +93,8 @@ static ECalBackendClass *parent_class = #define CURSOR_ITEM_LIMIT 100 #define CURSOR_ICALID_LIMIT 500 +#define d(x) + EGwConnection * e_cal_backend_groupwise_get_connection (ECalBackendGroupwise *cbgw) { @@ -289,7 +291,7 @@ get_deltas (gpointer handle) char *time_string = NULL; char t_str [100]; const char *serv_time; - static GStaticMutex connecting = G_STATIC_MUTEX_INIT; + static int connecting_atom = 0; const char *time_interval_string; const char *key = "attempts"; const char *attempts; @@ -319,7 +321,10 @@ get_deltas (gpointer handle) attempts = e_cal_backend_cache_get_key_value (cache, key); - g_static_mutex_lock (&connecting); + if (!g_atomic_int_compare_and_exchange (&connecting_atom, 0, 1)) { + d(g_print("%s:%s:%d: An updater thread is running already\n", __FILE__, __PRETTY_FUNCTION__, __LINE__)); + return TRUE; /* As another thread is already running, we return a TRUE as a sign of "not a failure" */ + } serv_time = e_cal_backend_cache_get_server_utc_time (cache); if (serv_time) { @@ -364,13 +369,13 @@ get_deltas (gpointer handle) } if (status == E_GW_CONNECTION_STATUS_NO_RESPONSE) { - g_static_mutex_unlock (&connecting); + g_atomic_int_compare_and_exchange (&connecting_atom, 1, 0); return TRUE; } msg = e_gw_connection_get_error_message (status); - g_static_mutex_unlock (&connecting); + g_atomic_int_compare_and_exchange (&connecting_atom, 1, 0); return TRUE; } @@ -446,12 +451,12 @@ get_deltas (gpointer handle) if (status != E_GW_CONNECTION_STATUS_OK) { if (status == E_GW_CONNECTION_STATUS_NO_RESPONSE) { - g_static_mutex_unlock (&connecting); + g_atomic_int_compare_and_exchange (&connecting_atom, 1, 0); return TRUE; } e_cal_backend_groupwise_notify_error_code (cbgw, status); - g_static_mutex_unlock (&connecting); + g_atomic_int_compare_and_exchange (&connecting_atom, 1, 0); return TRUE; } @@ -462,11 +467,11 @@ get_deltas (gpointer handle) status = e_gw_connection_read_cal_ids (cnc, cbgw->priv->container_id, cursor, FALSE, CURSOR_ICALID_LIMIT, position, &item_list); if (status != E_GW_CONNECTION_STATUS_OK) { if (status == E_GW_CONNECTION_STATUS_NO_RESPONSE) { - g_static_mutex_unlock (&connecting); + g_atomic_int_compare_and_exchange (&connecting_atom, 1, 0); return TRUE; } e_cal_backend_groupwise_notify_error_code (cbgw, status); - g_static_mutex_unlock (&connecting); + g_atomic_int_compare_and_exchange (&connecting_atom, 1, 0); return TRUE; } @@ -601,7 +606,7 @@ get_deltas (gpointer handle) g_slist_free (cache_keys); } - g_static_mutex_unlock (&connecting); + g_atomic_int_compare_and_exchange (&connecting_atom, 1, 0); return TRUE; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor