[gnome-online-accounts/gnome-3-12] identity: add some locking around expiration time
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/gnome-3-12] identity: add some locking around expiration time
- Date: Wed, 12 Nov 2014 14:32:59 +0000 (UTC)
commit ddceeee3f92b22ad60262e20fa6c1e22e7f8cbf7
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 2bdf59f..a5cd1b0 100644
--- a/src/goaidentity/goakerberosidentity.c
+++ b/src/goaidentity/goakerberosidentity.c
@@ -530,13 +530,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
@@ -544,11 +548,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]