[gnome-online-accounts] identity: add some locking around expiration time
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts] identity: add some locking around expiration time
- Date: Wed, 5 Nov 2014 19:02:55 +0000 (UTC)
commit 8d508f9ac79b1a6d7c9bb517d77ace9a5a699345
Author: Ray Strode <rstrode redhat com>
Date: Tue Oct 28 16:39:23 2014 -0400
identity: add some locking around expiration time
We don't want the expiration time to get read while it's getting
written.
https://bugzilla.gnome.org/show_bug.cgi?id=739593
src/goaidentity/goakerberosidentity.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/goaidentity/goakerberosidentity.c b/src/goaidentity/goakerberosidentity.c
index 8472eb0..67c74b4 100644
--- a/src/goaidentity/goakerberosidentity.c
+++ b/src/goaidentity/goakerberosidentity.c
@@ -528,13 +528,17 @@ static void
set_expiration_time (GoaKerberosIdentity *self,
krb5_timestamp expiration_time)
{
+ G_LOCK (identity_lock);
if (self->priv->expiration_time != expiration_time)
{
self->priv->expiration_time = expiration_time;
+ G_UNLOCK (identity_lock);
queue_notify (self,
&self->priv->expiration_time_idle_id,
"expiration-timestamp");
+ G_LOCK (identity_lock);
}
+ G_UNLOCK (identity_lock);
}
static gboolean
@@ -542,11 +546,16 @@ credentials_are_expired (GoaKerberosIdentity *self,
krb5_creds *credentials)
{
krb5_timestamp current_time;
+ krb5_timestamp expiration_time;
current_time = get_current_time (self);
- set_expiration_time (self, MAX (credentials->times.endtime,
- self->priv->expiration_time));
+ G_LOCK (identity_lock);
+ expiration_time = MAX (credentials->times.endtime,
+ self->priv->expiration_time);
+ G_UNLOCK (identity_lock);
+
+ set_expiration_time (self, expiration_time);
if (credentials->times.endtime <= current_time)
{
@@ -868,7 +877,9 @@ reset_alarms (GoaKerberosIdentity *self)
GTimeSpan time_span_until_expiration;
now = g_date_time_new_now_local ();
+ G_LOCK (identity_lock);
expiration_time = g_date_time_new_from_unix_local (self->priv->expiration_time);
+ G_UNLOCK (identity_lock);
time_span_until_expiration = g_date_time_difference (expiration_time, now);
g_date_time_unref (now);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]