summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-09-23 09:33:04 -0700
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-09-23 09:33:04 -0700
commit54a7a2f4e5a5cae1bef9f8edbcb4650e3d835c9f (patch)
tree41a5623b83ec480e1c2b5696289f08e266973bba /src
parent0c20e0b7a706307ffdb9a76c22634e9b2d50cc45 (diff)
Fix OffMode = DevDown race condition.
Diffstat (limited to 'src')
-rw-r--r--src/adapter.c11
-rw-r--r--src/main.c11
2 files changed, 8 insertions, 14 deletions
diff --git a/src/adapter.c b/src/adapter.c
index a59f2b12..4a6ea8c2 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2242,9 +2242,14 @@ static void adapter_up(struct btd_adapter *adapter, int dd)
/* Set scan mode */
if (read_device_mode(srcaddr, mode, sizeof(mode)) == 0) {
- if (!strcmp(mode, "off") && main_opts.offmode == HCID_OFFMODE_NOSCAN) {
- adapter->mode = MODE_OFF;
- adapter->scan_mode= SCAN_DISABLED;
+ if (!strcmp(mode, "off")) {
+ if (main_opts.offmode == HCID_OFFMODE_NOSCAN) {
+ adapter->mode = MODE_OFF;
+ adapter->scan_mode= SCAN_DISABLED;
+ } else if (main_opts.offmode == HCID_OFFMODE_DEVDOWN) {
+ ioctl(dd, HCIDEVDOWN, adapter->dev_id);
+ return;
+ }
} else if (!strcmp(mode, "connectable")) {
adapter->mode = MODE_CONNECTABLE;
adapter->scan_mode = SCAN_PAGE;
diff --git a/src/main.c b/src/main.c
index db257428..9bfeb512 100644
--- a/src/main.c
+++ b/src/main.c
@@ -452,17 +452,6 @@ static void init_device(int dev_id)
if (hci_test_bit(HCI_RAW, &di.flags))
goto done;
- if (main_opts.offmode == HCID_OFFMODE_DEVDOWN) {
- char mode[16], src[18];
-
- ba2str(&di.bdaddr, src);
- if (read_device_mode(src, mode, sizeof(mode)) == 0 &&
- strcmp(mode, "off") == 0) {
- ioctl(dd, HCIDEVDOWN, dev_id);
- goto done;
- }
- }
-
done:
hci_close_dev(dd);
exit(0);