From 21b98c75268567b3b0834fe5ca46f18781d3c78a Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Jun 21 2009 13:43:33 +0000 Subject: - Update to 4.42 --- diff --git a/.cvsignore b/.cvsignore index fd70aa6..9b39576 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1 +1 @@ -bluez-4.41.tar.gz +bluez-4.42.tar.gz diff --git a/0001-Add-udev-mode-to-bluetoothd.patch b/0001-Add-udev-mode-to-bluetoothd.patch deleted file mode 100644 index 3afd043..0000000 --- a/0001-Add-udev-mode-to-bluetoothd.patch +++ /dev/null @@ -1,219 +0,0 @@ -From 3e9257b31efcffbb8583f99770604b40a04410b2 Mon Sep 17 00:00:00 2001 -From: Bastien Nocera -Date: Thu, 11 Jun 2009 18:33:35 +0100 -Subject: [PATCH] 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. ---- - src/dbus-common.c | 18 +++++++++++---- - src/hcid.h | 3 ++ - src/main.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++--- - src/manager.c | 6 +++++ - 4 files changed, 81 insertions(+), 9 deletions(-) - -diff --git a/src/dbus-common.c b/src/dbus-common.c -index b596909..d06d8e5 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); - -diff --git a/src/hcid.h b/src/hcid.h -index 4fbbef1..605dc06 100644 ---- a/src/hcid.h -+++ b/src/hcid.h -@@ -85,6 +85,9 @@ void hci_req_queue_remove(int dev_id, bdaddr_t *dba); - void start_security_manager(int hdev); - void stop_security_manager(int hdev); - -+void btd_start_exit_timer(void); -+void btd_stop_exit_timer(void); -+ - void set_pin_length(bdaddr_t *sba, int length); - - gboolean plugin_init(GKeyFile *config); -diff --git a/src/main.c b/src/main.c -index 0467fe1..8c2b475 100644 ---- a/src/main.c -+++ b/src/main.c -@@ -27,6 +27,7 @@ - #include - #endif - -+#include - #include - #include - #include -@@ -55,6 +56,8 @@ - #include "agent.h" - #include "manager.h" - -+#define LAST_ADAPTER_EXIT_TIMEOUT 30 -+ - struct main_opts main_opts; - - static GKeyFile *load_config(const char *file) -@@ -331,6 +334,37 @@ static void sig_debug(int sig) - - static gboolean option_detach = TRUE; - static gboolean option_debug = FALSE; -+static gboolean option_udev = FALSE; -+ -+static guint last_adapter_timeout = 0; -+ -+static gboolean exit_timeout(gpointer data) -+{ -+ g_main_loop_quit(event_loop); -+ last_adapter_timeout = 0; -+ return FALSE; -+} -+ -+void btd_start_exit_timer(void) -+{ -+ if (option_udev == FALSE) -+ return; -+ -+ if (last_adapter_timeout > 0) -+ g_source_remove(last_adapter_timeout); -+ -+ last_adapter_timeout = g_timeout_add_seconds(LAST_ADAPTER_EXIT_TIMEOUT, -+ exit_timeout, NULL); -+} -+ -+void btd_stop_exit_timer(void) -+{ -+ if (last_adapter_timeout == 0) -+ return; -+ -+ g_source_remove(last_adapter_timeout); -+ last_adapter_timeout = 0; -+} - - static GOptionEntry options[] = { - { "nodaemon", 'n', G_OPTION_FLAG_REVERSE, -@@ -338,6 +372,8 @@ static GOptionEntry options[] = { - "Don't run as daemon in background" }, - { "debug", 'd', 0, G_OPTION_ARG_NONE, &option_debug, - "Enable debug information output" }, -+ { "udev", 'u', 0, G_OPTION_ARG_NONE, &option_udev, -+ "Run from udev mode of operation" }, - { NULL }, - }; - -@@ -363,9 +399,21 @@ int main(int argc, char *argv[]) - exit(1); - } - -+ if (option_udev == TRUE) { -+ int err; -+ -+ option_detach = TRUE; -+ err = hcid_dbus_init(); -+ if (err < 0) { -+ if (err == -EALREADY) -+ exit(0); -+ exit(1); -+ } -+ } -+ - g_option_context_free(context); - -- if (option_detach == TRUE) { -+ if (option_detach == TRUE && option_udev == FALSE) { - if (daemon(0, 0)) { - perror("Can't start daemon"); - exit(1); -@@ -399,9 +447,16 @@ int main(int argc, char *argv[]) - - agent_init(); - -- if (hcid_dbus_init() < 0) { -- error("Unable to get on D-Bus"); -- exit(1); -+ if (option_udev == FALSE) { -+ if (hcid_dbus_init() < 0) { -+ error("Unable to get on D-Bus"); -+ exit(1); -+ } -+ } else { -+ if (daemon(0, 0)) { -+ perror("Can't start daemon"); -+ exit(1); -+ } - } - - start_sdp_server(mtu, main_opts.deviceid, SDP_SERVER_COMPAT); -diff --git a/src/manager.c b/src/manager.c -index db6d251..ab69e4e 100644 ---- a/src/manager.c -+++ b/src/manager.c -@@ -43,6 +43,7 @@ - - #include - -+#include "hcid.h" - #include "dbus-common.h" - #include "logging.h" - #include "adapter.h" -@@ -312,6 +313,9 @@ static void manager_remove_adapter(struct btd_adapter *adapter) - DBUS_TYPE_INVALID); - - adapter_remove(adapter); -+ -+ if (adapters == NULL) -+ btd_start_exit_timer(); - } - - void manager_cleanup(DBusConnection *conn, const char *path) -@@ -421,6 +425,8 @@ void manager_add_adapter(const char *path) - DBUS_TYPE_INVALID); - - manager_update_adapters(); -+ -+ btd_stop_exit_timer(); - } - - int manager_register_adapter(int id, gboolean devup) --- -1.6.2.2 - diff --git a/0001-Add-udev-rules-to-start-bluetooth-on-demand.patch b/0001-Add-udev-rules-to-start-bluetooth-on-demand.patch new file mode 100644 index 0000000..21dfd58 --- /dev/null +++ b/0001-Add-udev-rules-to-start-bluetooth-on-demand.patch @@ -0,0 +1,39 @@ +From 830639ae0f3421a9d7c7366854925e32001771b5 Mon Sep 17 00:00:00 2001 +From: Bastien Nocera +Date: Sun, 21 Jun 2009 14:37:32 +0100 +Subject: [PATCH] Add udev rules to start bluetooth on-demand + +Those rules call bluetoothd --udev when a new dongle is inserted. +--- + scripts/96-bluez.rules | 5 +++++ + scripts/Makefile.am | 2 ++ + 2 files changed, 7 insertions(+), 0 deletions(-) + create mode 100644 scripts/96-bluez.rules + +diff --git a/scripts/96-bluez.rules b/scripts/96-bluez.rules +new file mode 100644 +index 0000000..f3034b5 +--- /dev/null ++++ b/scripts/96-bluez.rules +@@ -0,0 +1,5 @@ ++# Run helper every time a Bluetooth device appears ++# On remove actions, bluetoothd should go away by itself ++ ++ACTION=="add", SUBSYSTEM=="bluetooth", RUN+="/usr/sbin/bluetoothd --udev" ++ +diff --git a/scripts/Makefile.am b/scripts/Makefile.am +index 494a9c2..d87295d 100644 +--- a/scripts/Makefile.am ++++ b/scripts/Makefile.am +@@ -11,6 +11,8 @@ endif + if PCMCIARULES + rules_DATA += bluetooth-serial.rules + endif ++ ++rules_DATA += 96-bluez.rules + endif + + if PCMCIARULES +-- +1.6.2.2 + diff --git a/96-bluez.rules b/96-bluez.rules deleted file mode 100644 index f3034b5..0000000 --- a/96-bluez.rules +++ /dev/null @@ -1,5 +0,0 @@ -# Run helper every time a Bluetooth device appears -# On remove actions, bluetoothd should go away by itself - -ACTION=="add", SUBSYSTEM=="bluetooth", RUN+="/usr/sbin/bluetoothd --udev" - diff --git a/bluez.spec b/bluez.spec index da62526..1eaf526 100644 --- a/bluez.spec +++ b/bluez.spec @@ -1,6 +1,6 @@ Summary: Bluetooth utilities Name: bluez -Version: 4.41 +Version: 4.42 Release: 2%{?dist} License: GPLv2+ Group: Applications/System @@ -25,8 +25,8 @@ Patch3: bluez-activate-wacom-mode2.patch Patch4: bluez-socket-mobile-cf-connection-kit.patch # http://thread.gmane.org/gmane.linux.bluez.kernel/2396 Patch5: 0001-Add-sixaxis-cable-pairing-plugin.patch -# http://thread.gmane.org/gmane.linux.bluez.kernel/2474 -Patch6: 0001-Add-udev-mode-to-bluetoothd.patch +# http://thread.gmane.org/gmane.linux.bluez.kernel/2579 +Patch6: 0001-Add-udev-rules-to-start-bluetooth-on-demand.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root URL: http://www.bluez.org/ @@ -273,6 +273,9 @@ fi %config(noreplace) %{_sysconfdir}/sysconfig/pand %changelog +* Sun Jun 21 2009 Bastien Nocera 4.42-2 +- Update to 4.42 + * Thu Jun 11 2009 Bastien Nocera 4.41-2 - Switch to on-demand start/stop using udev diff --git a/sources b/sources index f00fe67..17a8a27 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -4629236517df280be321f009917a52be bluez-4.41.tar.gz +d24dfd3ca42847123e29f58b29af6948 bluez-4.42.tar.gz