[evolution-data-server] ECalClient: Increment/decrement active client count atomically.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] ECalClient: Increment/decrement active client count atomically.
- Date: Fri, 1 Feb 2013 13:59:51 +0000 (UTC)
commit 910342f759e177267ff31b53b6acd20f94892cb7
Author: Matthew Barnes <mbarnes redhat com>
Date: Fri Feb 1 08:40:45 2013 -0500
ECalClient: Increment/decrement active client count atomically.
It's basically a reference count. Avoids using the recursive mutex.
calendar/libecal/e-cal-client.c | 14 +++++---------
1 files changed, 5 insertions(+), 9 deletions(-)
---
diff --git a/calendar/libecal/e-cal-client.c b/calendar/libecal/e-cal-client.c
index f21c028..557c696 100644
--- a/calendar/libecal/e-cal-client.c
+++ b/calendar/libecal/e-cal-client.c
@@ -343,7 +343,8 @@ set_proxy_gone_error (GError **error)
g_set_error_literal (error, E_CLIENT_ERROR, E_CLIENT_ERROR_DBUS_ERROR, "D-Bus calendar proxy gone");
}
-static guint active_cal_clients = 0, cal_connection_closed_id = 0;
+static volatile gint active_cal_clients = 0;
+static guint cal_connection_closed_id = 0;
static EDBusCalendarFactory *cal_factory = NULL;
static GRecMutex cal_factory_lock;
#define LOCK_FACTORY() g_rec_mutex_lock (&cal_factory_lock)
@@ -391,7 +392,7 @@ gdbus_cal_factory_closed_cb (GDBusConnection *connection,
if (err) {
g_debug ("GDBus connection is closed%s: %s", remote_peer_vanished ? ", remote peer vanished" : "", err->message);
g_error_free (err);
- } else if (active_cal_clients) {
+ } else if (active_cal_clients > 0) {
g_debug ("GDBus connection is closed%s", remote_peer_vanished ? ", remote peer vanished" : "");
}
@@ -935,11 +936,8 @@ cal_client_finalize (GObject *object)
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (e_cal_client_parent_class)->finalize (object);
- LOCK_FACTORY ();
- active_cal_clients--;
- if (!active_cal_clients)
+ if (g_atomic_int_dec_and_test (&active_cal_clients))
gdbus_cal_factory_disconnect (NULL);
- UNLOCK_FACTORY ();
}
static GDBusProxy *
@@ -1498,9 +1496,7 @@ e_cal_client_init (ECalClient *client)
(GDestroyNotify) g_free,
(GDestroyNotify) free_zone_cb);
- LOCK_FACTORY ();
- active_cal_clients++;
- UNLOCK_FACTORY ();
+ g_atomic_int_inc (&active_cal_clients);
client->priv = E_CAL_CLIENT_GET_PRIVATE (client);
client->priv->source_type = E_CAL_CLIENT_SOURCE_TYPE_LAST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]