[evolution-data-server] Remove e_cal_backend_sync_set_lock().
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Remove e_cal_backend_sync_set_lock().
- Date: Tue, 2 Apr 2013 19:04:36 +0000 (UTC)
commit 915ceb313acb2e8d4066aa6866e7f12b643c0cab
Author: Matthew Barnes <mbarnes redhat com>
Date: Tue Apr 2 14:33:09 2013 -0400
Remove e_cal_backend_sync_set_lock().
ECalBackendSync purports to offer serialized method dispatching but
implements it completely wrong. Backends which rely on this should
instead set use_serial_dispatch_queue in their class_init() method.
calendar/backends/caldav/e-cal-backend-caldav.c | 2 -
.../backends/contacts/e-cal-backend-contacts.c | 5 +-
calendar/backends/file/e-cal-backend-file.c | 6 -
calendar/backends/http/e-cal-backend-http.c | 5 +-
calendar/backends/weather/e-cal-backend-weather.c | 5 +-
calendar/libedata-cal/e-cal-backend-sync.c | 108 +++++++-------------
calendar/libedata-cal/e-cal-backend-sync.h | 2 -
.../libedata-cal/libedata-cal-sections.txt | 1 -
8 files changed, 44 insertions(+), 90 deletions(-)
---
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c
index ebca58e..58c70b6 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -5234,8 +5234,6 @@ e_cal_backend_caldav_init (ECalBackendCalDAV *cbdav)
cbdav->priv->session, "authenticate",
G_CALLBACK (soup_authenticate), cbdav);
- e_cal_backend_sync_set_lock (E_CAL_BACKEND_SYNC (cbdav), FALSE);
-
g_signal_connect (
cbdav, "notify::online",
G_CALLBACK (caldav_notify_online_cb), NULL);
diff --git a/calendar/backends/contacts/e-cal-backend-contacts.c
b/calendar/backends/contacts/e-cal-backend-contacts.c
index 03326a7..03aa26e 100644
--- a/calendar/backends/contacts/e-cal-backend-contacts.c
+++ b/calendar/backends/contacts/e-cal-backend-contacts.c
@@ -1316,8 +1316,6 @@ e_cal_backend_contacts_init (ECalBackendContacts *cbc)
cbc->priv->alarm_interval = -1;
cbc->priv->alarm_units = CAL_MINUTES;
- e_cal_backend_sync_set_lock (E_CAL_BACKEND_SYNC (cbc), TRUE);
-
g_signal_connect (
cbc, "notify::online",
G_CALLBACK (e_cal_backend_contacts_notify_online_cb), NULL);
@@ -1353,6 +1351,9 @@ e_cal_backend_contacts_class_init (ECalBackendContactsClass *class)
object_class->dispose = e_cal_backend_contacts_dispose;
object_class->constructed = e_cal_backend_contacts_constructed;
+ /* Execute one method at a time. */
+ backend_class->use_serial_dispatch_queue = TRUE;
+
backend_class->get_backend_property = e_cal_backend_contacts_get_backend_property;
sync_class->open_sync = e_cal_backend_contacts_open;
diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c
index f4aa5be..adc9e99 100644
--- a/calendar/backends/file/e-cal-backend-file.c
+++ b/calendar/backends/file/e-cal-backend-file.c
@@ -3553,12 +3553,6 @@ e_cal_backend_file_init (ECalBackendFile *cbfile)
g_rec_mutex_init (&cbfile->priv->idle_save_rmutex);
g_mutex_init (&cbfile->priv->refresh_lock);
-
- /*
- * data access is serialized via idle_save_rmutex, so locking at the
- * backend method level is not needed
- */
- e_cal_backend_sync_set_lock (E_CAL_BACKEND_SYNC (cbfile), FALSE);
}
void
diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c
index 8e2e179..1765dc2 100644
--- a/calendar/backends/http/e-cal-backend-http.c
+++ b/calendar/backends/http/e-cal-backend-http.c
@@ -1468,8 +1468,6 @@ e_cal_backend_http_init (ECalBackendHttp *cbhttp)
{
cbhttp->priv = E_CAL_BACKEND_HTTP_GET_PRIVATE (cbhttp);
- e_cal_backend_sync_set_lock (E_CAL_BACKEND_SYNC (cbhttp), TRUE);
-
g_signal_connect (
cbhttp, "notify::online",
G_CALLBACK (e_cal_backend_http_notify_online_cb), NULL);
@@ -1493,6 +1491,9 @@ e_cal_backend_http_class_init (ECalBackendHttpClass *class)
object_class->finalize = e_cal_backend_http_finalize;
object_class->constructed = e_cal_backend_http_constructed;
+ /* Execute one method at a time. */
+ backend_class->use_serial_dispatch_queue = TRUE;
+
backend_class->get_backend_property = e_cal_backend_http_get_backend_property;
sync_class->open_sync = e_cal_backend_http_open;
diff --git a/calendar/backends/weather/e-cal-backend-weather.c
b/calendar/backends/weather/e-cal-backend-weather.c
index 68ccaaf..ae962a8 100644
--- a/calendar/backends/weather/e-cal-backend-weather.c
+++ b/calendar/backends/weather/e-cal-backend-weather.c
@@ -782,8 +782,6 @@ e_cal_backend_weather_init (ECalBackendWeather *cbw)
{
cbw->priv = E_CAL_BACKEND_WEATHER_GET_PRIVATE (cbw);
- e_cal_backend_sync_set_lock (E_CAL_BACKEND_SYNC (cbw), TRUE);
-
g_signal_connect (
cbw, "notify::online",
G_CALLBACK (e_cal_backend_weather_notify_online_cb), NULL);
@@ -805,6 +803,9 @@ e_cal_backend_weather_class_init (ECalBackendWeatherClass *class)
object_class->finalize = e_cal_backend_weather_finalize;
+ /* Execute one method at a time. */
+ backend_class->use_serial_dispatch_queue = TRUE;
+
backend_class->get_backend_property = e_cal_backend_weather_get_backend_property;
sync_class->open_sync = e_cal_backend_weather_open;
diff --git a/calendar/libedata-cal/e-cal-backend-sync.c b/calendar/libedata-cal/e-cal-backend-sync.c
index 666b201..6dd5fe1 100644
--- a/calendar/libedata-cal/e-cal-backend-sync.c
+++ b/calendar/libedata-cal/e-cal-backend-sync.c
@@ -22,40 +22,6 @@
G_DEFINE_TYPE (ECalBackendSync, e_cal_backend_sync, E_TYPE_CAL_BACKEND)
-struct _ECalBackendSyncPrivate {
- GMutex sync_mutex;
-
- gboolean mutex_lock;
-};
-
-#define LOCK_WRAPPER(func, args) G_STMT_START {
\
- gboolean locked = backend->priv->mutex_lock;
\
- if (locked)
\
- g_mutex_lock (&backend->priv->sync_mutex);
\
- (* E_CAL_BACKEND_SYNC_GET_CLASS (backend)->func) args;
\
- if (locked)
\
- g_mutex_unlock (&backend->priv->sync_mutex);
\
- } G_STMT_END
-
-/**
- * e_cal_backend_sync_set_lock:
- * @backend: An ECalBackendSync object.
- * @lock: Lock mode.
- *
- * Sets the lock mode on the ECalBackendSync object. If TRUE, the backend
- * will create a locking mutex for every operation, so that only one can
- * happen at a time. If FALSE, no lock would be done and many operations
- * can happen at the same time.
- */
-void
-e_cal_backend_sync_set_lock (ECalBackendSync *backend,
- gboolean lock)
-{
- g_return_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend));
-
- backend->priv->mutex_lock = lock;
-}
-
/**
* e_cal_backend_sync_open:
* @backend: An ECalBackendSync object.
@@ -80,7 +46,8 @@ e_cal_backend_sync_open (ECalBackendSync *backend,
class = E_CAL_BACKEND_SYNC_GET_CLASS (backend);
if (class->open_sync != NULL) {
- LOCK_WRAPPER (open_sync, (backend, cal, cancellable, only_if_exists, error));
+ class->open_sync (
+ backend, cal, cancellable, only_if_exists, error);
} else {
g_set_error_literal (
error, E_CLIENT_ERROR,
@@ -113,7 +80,7 @@ e_cal_backend_sync_refresh (ECalBackendSync *backend,
class = E_CAL_BACKEND_SYNC_GET_CLASS (backend);
if (class->refresh_sync != NULL) {
- LOCK_WRAPPER (refresh_sync, (backend, cal, cancellable, error));
+ class->refresh_sync (backend, cal, cancellable, error);
} else {
g_set_error_literal (
error, E_CLIENT_ERROR,
@@ -152,7 +119,8 @@ e_cal_backend_sync_get_object (ECalBackendSync *backend,
class = E_CAL_BACKEND_SYNC_GET_CLASS (backend);
if (class->get_object_sync != NULL) {
- LOCK_WRAPPER (get_object_sync, (backend, cal, cancellable, uid, rid, calobj, error));
+ class->get_object_sync (
+ backend, cal, cancellable, uid, rid, calobj, error);
} else {
g_set_error_literal (
error, E_CLIENT_ERROR,
@@ -188,7 +156,8 @@ e_cal_backend_sync_get_object_list (ECalBackendSync *backend,
class = E_CAL_BACKEND_SYNC_GET_CLASS (backend);
if (class->get_object_list_sync != NULL) {
- LOCK_WRAPPER (get_object_list_sync, (backend, cal, cancellable, sexp, calobjs, error));
+ class->get_object_list_sync (
+ backend, cal, cancellable, sexp, calobjs, error);
} else {
g_set_error_literal (
error, E_CLIENT_ERROR,
@@ -227,7 +196,9 @@ e_cal_backend_sync_get_free_busy (ECalBackendSync *backend,
class = E_CAL_BACKEND_SYNC_GET_CLASS (backend);
if (class->get_free_busy_sync != NULL) {
- LOCK_WRAPPER (get_free_busy_sync, (backend, cal, cancellable, users, start, end,
freebusyobjects, error));
+ class->get_free_busy_sync (
+ backend, cal, cancellable,
+ users, start, end, freebusyobjects, error);
} else {
g_set_error_literal (
error, E_CLIENT_ERROR,
@@ -266,7 +237,9 @@ e_cal_backend_sync_create_objects (ECalBackendSync *backend,
class = E_CAL_BACKEND_SYNC_GET_CLASS (backend);
if (class->create_objects_sync != NULL) {
- LOCK_WRAPPER (create_objects_sync, (backend, cal, cancellable, calobjs, uids, new_components,
error));
+ class->create_objects_sync (
+ backend, cal, cancellable,
+ calobjs, uids, new_components, error);
} else {
g_set_error_literal (
error, E_CLIENT_ERROR,
@@ -309,7 +282,9 @@ e_cal_backend_sync_modify_objects (ECalBackendSync *backend,
class = E_CAL_BACKEND_SYNC_GET_CLASS (backend);
if (class->modify_objects_sync != NULL) {
- LOCK_WRAPPER (modify_objects_sync, (backend, cal, cancellable, calobjs, mod, old_components,
new_components, error));
+ class->modify_objects_sync (
+ backend, cal, cancellable,
+ calobjs, mod, old_components, new_components, error);
} else {
g_set_error_literal (
error, E_CLIENT_ERROR,
@@ -353,7 +328,9 @@ e_cal_backend_sync_remove_objects (ECalBackendSync *backend,
class = E_CAL_BACKEND_SYNC_GET_CLASS (backend);
if (class->remove_objects_sync != NULL) {
- LOCK_WRAPPER (remove_objects_sync, (backend, cal, cancellable, ids, mod, old_components,
new_components, error));
+ class->remove_objects_sync (
+ backend, cal, cancellable,
+ ids, mod, old_components, new_components, error);
} else {
g_set_error_literal (
error, E_CLIENT_ERROR,
@@ -386,7 +363,8 @@ e_cal_backend_sync_receive_objects (ECalBackendSync *backend,
class = E_CAL_BACKEND_SYNC_GET_CLASS (backend);
if (class->receive_objects_sync != NULL) {
- LOCK_WRAPPER (receive_objects_sync, (backend, cal, cancellable, calobj, error));
+ class->receive_objects_sync (
+ backend, cal, cancellable, calobj, error);
} else {
g_set_error_literal (
error, E_CLIENT_ERROR,
@@ -423,7 +401,9 @@ e_cal_backend_sync_send_objects (ECalBackendSync *backend,
class = E_CAL_BACKEND_SYNC_GET_CLASS (backend);
if (class->send_objects_sync != NULL) {
- LOCK_WRAPPER (send_objects_sync, (backend, cal, cancellable, calobj, users, modified_calobj,
error));
+ class->send_objects_sync (
+ backend, cal, cancellable,
+ calobj, users, modified_calobj, error);
} else {
g_set_error_literal (
error, E_CLIENT_ERROR,
@@ -463,7 +443,9 @@ e_cal_backend_sync_get_attachment_uris (ECalBackendSync *backend,
class = E_CAL_BACKEND_SYNC_GET_CLASS (backend);
if (class->get_attachment_uris_sync != NULL) {
- LOCK_WRAPPER (get_attachment_uris_sync, (backend, cal, cancellable, uid, rid, attachments,
error));
+ class->get_attachment_uris_sync (
+ backend, cal, cancellable,
+ uid, rid, attachments, error);
} else {
g_set_error_literal (
error, E_CLIENT_ERROR,
@@ -502,7 +484,9 @@ e_cal_backend_sync_discard_alarm (ECalBackendSync *backend,
class = E_CAL_BACKEND_SYNC_GET_CLASS (backend);
if (class->discard_alarm_sync != NULL) {
- LOCK_WRAPPER (discard_alarm_sync, (backend, cal, cancellable, uid, rid, auid, error));
+ class->discard_alarm_sync (
+ backend, cal, cancellable,
+ uid, rid, auid, error);
} else {
g_set_error_literal (
error, E_CLIENT_ERROR,
@@ -543,18 +527,16 @@ e_cal_backend_sync_get_timezone (ECalBackendSync *backend,
class = E_CAL_BACKEND_SYNC_GET_CLASS (backend);
if (class->get_timezone_sync != NULL) {
- LOCK_WRAPPER (get_timezone_sync, (backend, cal, cancellable, tzid, tzobject, error));
+ class->get_timezone_sync (
+ backend, cal, cancellable,
+ tzid, tzobject, error);
}
if (tzobject && !*tzobject) {
icaltimezone *zone = NULL;
- if (backend->priv->mutex_lock)
- g_mutex_lock (&backend->priv->sync_mutex);
zone = e_timezone_cache_get_timezone (
E_TIMEZONE_CACHE (backend), tzid);
- if (backend->priv->mutex_lock)
- g_mutex_unlock (&backend->priv->sync_mutex);
if (!zone) {
g_propagate_error (error, e_data_cal_create_error (ObjectNotFound, NULL));
@@ -595,7 +577,8 @@ e_cal_backend_sync_add_timezone (ECalBackendSync *backend,
class = E_CAL_BACKEND_SYNC_GET_CLASS (backend);
if (class->add_timezone_sync != NULL) {
- LOCK_WRAPPER (add_timezone_sync, (backend, cal, cancellable, tzobject, error));
+ class->add_timezone_sync (
+ backend, cal, cancellable, tzobject, error);
} else {
g_set_error_literal (
error, E_CLIENT_ERROR,
@@ -917,29 +900,10 @@ cal_backend_add_timezone (ECalBackend *backend,
}
static void
-e_cal_backend_sync_finalize (GObject *object)
-{
- ECalBackendSyncPrivate *priv;
-
- priv = E_CAL_BACKEND_SYNC_GET_PRIVATE (object);
-
- g_mutex_clear (&priv->sync_mutex);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_cal_backend_sync_parent_class)->finalize (object);
-}
-
-static void
e_cal_backend_sync_class_init (ECalBackendSyncClass *class)
{
- GObjectClass *object_class;
ECalBackendClass *backend_class;
- g_type_class_add_private (class, sizeof (ECalBackendSyncPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->finalize = e_cal_backend_sync_finalize;
-
backend_class = E_CAL_BACKEND_CLASS (class);
backend_class->open = cal_backend_open;
backend_class->refresh = cal_backend_refresh;
@@ -960,7 +924,5 @@ e_cal_backend_sync_class_init (ECalBackendSyncClass *class)
static void
e_cal_backend_sync_init (ECalBackendSync *backend)
{
- backend->priv = E_CAL_BACKEND_SYNC_GET_PRIVATE (backend);
- g_mutex_init (&backend->priv->sync_mutex);
}
diff --git a/calendar/libedata-cal/e-cal-backend-sync.h b/calendar/libedata-cal/e-cal-backend-sync.h
index f749d70..2baec86 100644
--- a/calendar/libedata-cal/e-cal-backend-sync.h
+++ b/calendar/libedata-cal/e-cal-backend-sync.h
@@ -149,8 +149,6 @@ struct _ECalBackendSyncClass {
};
GType e_cal_backend_sync_get_type (void) G_GNUC_CONST;
-void e_cal_backend_sync_set_lock (ECalBackendSync *backend,
- gboolean lock);
void e_cal_backend_sync_open (ECalBackendSync *backend,
EDataCal *cal,
GCancellable *cancellable,
diff --git a/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt
b/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt
index f6d5aae..6c670ef 100644
--- a/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt
+++ b/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt
@@ -207,7 +207,6 @@ ECalBackendSExpPrivate
<FILE>e-cal-backend-sync</FILE>
<TITLE>ECalBackendSync</TITLE>
ECalBackendSync
-e_cal_backend_sync_set_lock
e_cal_backend_sync_open
e_cal_backend_sync_refresh
e_cal_backend_sync_get_object
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]