[gnome-boxes] Avoid deadlock during startup
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Avoid deadlock during startup
- Date: Wed, 23 May 2012 18:43:29 +0000 (UTC)
commit d1e6add7cbeb9bfab7190061db946512578dab22
Author: Alexander Larsson <alexl redhat com>
Date: Wed May 23 20:15:16 2012 +0200
Avoid deadlock during startup
UnattendedInstaller was doing a sync dbus call in the class
initializer. This is a no-no in GObject because the class initializer
is called with a recursive lock held, and the dbus call will wait
for the dbus thread to reply, but the dbus thread may create a
GObject and thus need the class_init lock, which causes a deadlock.
https://bugzilla.gnome.org/show_bug.cgi?id=676679
src/unattended-installer.vala | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index 8637ef1..d16d49d 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -50,7 +50,7 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
private static Regex password_regex;
private static Regex timezone_regex;
private static Regex lang_regex;
- private static Fdo.Accounts accounts;
+ private static Fdo.Accounts? accounts;
static construct {
try {
@@ -58,17 +58,23 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
password_regex = new Regex ("BOXES_PASSWORD");
timezone_regex = new Regex ("BOXES_TZ");
lang_regex = new Regex ("BOXES_LANG");
+ } catch (RegexError error) {
+ // This just can't fail
+ assert_not_reached ();
+ }
+ }
+
+ construct {
+ /* We can't do this in the class constructor as the sync call can
+ cause deadlocks, see bug #676679. */
+ if (accounts == null) {
try {
accounts = Bus.get_proxy_sync (BusType.SYSTEM, "org.freedesktop.Accounts", "/org/freedesktop/Accounts");
} catch (GLib.Error error) {
warning ("Failed to connect to D-Bus service '%s': %s", "org.freedesktop.Accounts", error.message);
}
- } catch (RegexError error) {
- // This just can't fail
- assert_not_reached ();
}
}
-
public UnattendedInstaller.copy (InstallerMedia media,
string unattended_src_path,
string unattended_dest_name) throws GLib.Error {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]