[glib] GSettings Registry Backend: Init cache_lock Earlier
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GSettings Registry Backend: Init cache_lock Earlier
- Date: Thu, 20 Nov 2014 14:11:37 +0000 (UTC)
commit f6bbd19beb41aeb52426ba96b3c39c1b09f6bc17
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Thu Nov 20 18:34:21 2014 +0800
GSettings Registry Backend: Init cache_lock Earlier
In commit 8ff5668, we are subscribing the GSettings backend later, but this
meant that we need to initialize cache_lock earlier, as we might try to
use that lock before a change notification is issued to subscribe the
backend, which would then cause an access violation if we are trying to
read GSettings values, as that lock is used to access the Windows Registry.
Initialize cache_lock once we initialize the GSettings Registry backend,
and delete it upon finalize, so that g_settings_read_from_backend() can
proceed normally, even if the GSettings backend is not yet subscribed.
https://bugzilla.gnome.org/show_bug.cgi?id=740413
gio/gregistrysettingsbackend.c | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/gio/gregistrysettingsbackend.c b/gio/gregistrysettingsbackend.c
index cf9da0b..96df52c 100644
--- a/gio/gregistrysettingsbackend.c
+++ b/gio/gregistrysettingsbackend.c
@@ -1654,9 +1654,6 @@ watch_start (GRegistryBackend *self)
g_return_val_if_fail (self->watch == NULL, FALSE);
- self->cache_lock = g_slice_new (CRITICAL_SECTION);
- InitializeCriticalSection (self->cache_lock);
-
watch = g_slice_new (WatchThreadState);
watch->owner = G_SETTINGS_BACKEND (self);
@@ -1685,8 +1682,6 @@ watch_start (GRegistryBackend *self)
return TRUE;
fail_2:
- DeleteCriticalSection (self->cache_lock);
- g_slice_free (CRITICAL_SECTION, self->cache_lock);
DeleteCriticalSection (watch->message_lock);
g_slice_free (CRITICAL_SECTION, watch->message_lock);
CloseHandle (watch->message_sent_event);
@@ -1720,9 +1715,7 @@ watch_stop_unlocked (GRegistryBackend *self)
LeaveCriticalSection (watch->message_lock);
DeleteCriticalSection (watch->message_lock);
- DeleteCriticalSection (self->cache_lock);
g_slice_free (CRITICAL_SECTION, watch->message_lock);
- g_slice_free (CRITICAL_SECTION, self->cache_lock);
CloseHandle (watch->message_sent_event);
CloseHandle (watch->message_received_event);
CloseHandle (watch->thread);
@@ -1936,6 +1929,9 @@ g_registry_backend_finalize (GObject *object)
watch_stop_unlocked (self);
}
+ DeleteCriticalSection (self->cache_lock);
+ g_slice_free (CRITICAL_SECTION, self->cache_lock);
+
g_free (self->base_path);
}
@@ -1970,5 +1966,8 @@ g_registry_backend_init (GRegistryBackend *self)
item->ref_count = 1;
self->cache_root = g_node_new (item);
+ self->cache_lock = g_slice_new (CRITICAL_SECTION);
+ InitializeCriticalSection (self->cache_lock);
+
self->watch = NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]