1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Wed, 29 May 2013 13:45:31 +0000
Subject: [PATCH] 0.112: Use GOnce for interface type registration
Static local variable may not be enough since it doesn't provide locking.
Related to these udisksd warnings:
GLib-GObject-WARNING **: cannot register existing type `PolkitSubject'
Thanks to Hans de Goede for spotting this!
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65130
Origin: upstream, 0.112, commit:20ad116a6582e57d20f9d8197758947918753a4c
Imported from policykit-1_0.105-25.debian.tar.xz
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
src/polkit/polkitidentity.c | 10 ++++++----
src/polkit/polkitsubject.c | 10 ++++++----
src/polkitbackend/polkitbackendactionlookup.c | 10 ++++++----
3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/src/polkit/polkitidentity.c b/src/polkit/polkitidentity.c
index dd15b2f94828..7813c2c07919 100644
--- a/src/polkit/polkitidentity.c
+++ b/src/polkit/polkitidentity.c
@@ -49,9 +49,9 @@ base_init (gpointer g_iface)
GType
polkit_identity_get_type (void)
{
- static GType iface_type = 0;
+ static volatile gsize g_define_type_id__volatile = 0;
- if (iface_type == 0)
+ if (g_once_init_enter (&g_define_type_id__volatile))
{
static const GTypeInfo info =
{
@@ -67,12 +67,14 @@ polkit_identity_get_type (void)
NULL /* value_table */
};
- iface_type = g_type_register_static (G_TYPE_INTERFACE, "PolkitIdentity", &info, 0);
+ GType iface_type =
+ g_type_register_static (G_TYPE_INTERFACE, "PolkitIdentity", &info, 0);
g_type_interface_add_prerequisite (iface_type, G_TYPE_OBJECT);
+ g_once_init_leave (&g_define_type_id__volatile, iface_type);
}
- return iface_type;
+ return g_define_type_id__volatile;
}
/**
diff --git a/src/polkit/polkitsubject.c b/src/polkit/polkitsubject.c
index d2c4c205b1f2..aed57951bb6b 100644
--- a/src/polkit/polkitsubject.c
+++ b/src/polkit/polkitsubject.c
@@ -50,9 +50,9 @@ base_init (gpointer g_iface)
GType
polkit_subject_get_type (void)
{
- static GType iface_type = 0;
+ static volatile gsize g_define_type_id__volatile = 0;
- if (iface_type == 0)
+ if (g_once_init_enter (&g_define_type_id__volatile))
{
static const GTypeInfo info =
{
@@ -68,12 +68,14 @@ polkit_subject_get_type (void)
NULL /* value_table */
};
- iface_type = g_type_register_static (G_TYPE_INTERFACE, "PolkitSubject", &info, 0);
+ GType iface_type =
+ g_type_register_static (G_TYPE_INTERFACE, "PolkitSubject", &info, 0);
g_type_interface_add_prerequisite (iface_type, G_TYPE_OBJECT);
+ g_once_init_leave (&g_define_type_id__volatile, iface_type);
}
- return iface_type;
+ return g_define_type_id__volatile;
}
/**
diff --git a/src/polkitbackend/polkitbackendactionlookup.c b/src/polkitbackend/polkitbackendactionlookup.c
index 5a1a228a4c10..20747e7921ef 100644
--- a/src/polkitbackend/polkitbackendactionlookup.c
+++ b/src/polkitbackend/polkitbackendactionlookup.c
@@ -74,9 +74,9 @@ base_init (gpointer g_iface)
GType
polkit_backend_action_lookup_get_type (void)
{
- static GType iface_type = 0;
+ static volatile gsize g_define_type_id__volatile = 0;
- if (iface_type == 0)
+ if (g_once_init_enter (&g_define_type_id__volatile))
{
static const GTypeInfo info =
{
@@ -92,12 +92,14 @@ polkit_backend_action_lookup_get_type (void)
NULL /* value_table */
};
- iface_type = g_type_register_static (G_TYPE_INTERFACE, "PolkitBackendActionLookup", &info, 0);
+ GType iface_type =
+ g_type_register_static (G_TYPE_INTERFACE, "PolkitBackendActionLookup", &info, 0);
g_type_interface_add_prerequisite (iface_type, G_TYPE_OBJECT);
+ g_once_init_leave (&g_define_type_id__volatile, iface_type);
}
- return iface_type;
+ return g_define_type_id__volatile;
}
/**
|