diff options
author | Bastien Nocera <hadess@hadess.net> | 2009-06-11 18:33:35 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-06-11 19:47:44 +0200 |
commit | 03971a2d726bc9a8630b2419508235a2920eb19f (patch) | |
tree | 7e81634d6a597d621db924adb20ddf70995efda3 /src/dbus-common.c | |
parent | f8c3e9f4a68af6e6687e754f871e03e2e8cc80b8 (diff) | |
download | bluez-03971a2d726bc9a8630b2419508235a2920eb19f.tar.gz |
Add udev mode to bluetoothd
Add --udev option to bluetoothd, to allow it to be started on-demand
from udev.
When a new adapter appears, udev would launch bluetoothd --udev.
To avoid problems with udev, bluetoothd --udev would only return
an error exit code if it wasn't already running and a real error
occurred.
When no more Bluetooth adapter are present on the system, bluetoothd
will exit after a 30 second timeout.
Diffstat (limited to 'src/dbus-common.c')
-rw-r--r-- | src/dbus-common.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/dbus-common.c b/src/dbus-common.c index b5969096e..d06d8e5a5 100644 --- a/src/dbus-common.c +++ b/src/dbus-common.c @@ -165,19 +165,27 @@ void hcid_dbus_exit(void) int hcid_dbus_init(void) { DBusConnection *conn; + DBusError err; - conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, BLUEZ_NAME, NULL); - if (!conn) - return -1; + dbus_error_init(&err); + + conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, BLUEZ_NAME, &err); + if (!conn) { + if (error != NULL && dbus_error_is_set(&err)) { + dbus_error_free(&err); + return -EIO; + } + return -EALREADY; + } if (g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL) == FALSE) { dbus_connection_unref(conn); - return -1; + return -EIO; } if (!manager_init(conn, "/")) - return -1; + return -EIO; set_dbus_connection(conn); |