From: Adam Lee <adam8157@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Marcel Holtmann <marcel@holtmann.org>
Subject: [PATCH BlueZ] core: retry connect_dbus() several times
Date: Fri, 28 Feb 2014 15:09:22 +0800 [thread overview]
Message-ID: <1393571362-27898-1-git-send-email-adam8157@gmail.com> (raw)
Sometimes the hardware, especially which needs firmware patching, is not
yet ready when connect_dbus().
Signed-off-by: Adam Lee <adam8157@gmail.com>
---
src/main.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/main.c b/src/main.c
index b3136fc..cf1f8fa 100644
--- a/src/main.c
+++ b/src/main.c
@@ -491,6 +491,7 @@ int main(int argc, char *argv[])
GKeyFile *config;
guint signal, watchdog;
const char *watchdog_usec;
+ uint8_t reconnect_times = 3;
init_defaults();
@@ -527,9 +528,17 @@ int main(int argc, char *argv[])
parse_config(config);
- if (connect_dbus() < 0) {
- error("Unable to get on D-Bus");
- exit(1);
+ /* Reconnect several times in case the hardware is not ready */
+ while (reconnect_times--) {
+ if (connect_dbus() == 0)
+ break;
+
+ if (reconnect_times != 1) {
+ usleep(500 * 1000);
+ } else {
+ error("Unable to get on D-Bus");
+ exit(1);
+ }
}
if (option_experimental)
--
1.9.0
next reply other threads:[~2014-02-28 7:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-28 7:09 Adam Lee [this message]
2014-02-28 7:15 ` [PATCH BlueZ] core: retry connect_dbus() several times Marcel Holtmann
2014-02-28 7:31 ` Adam Lee
2014-02-28 7:40 ` Marcel Holtmann
2014-02-28 12:22 ` Anderson Lizardo
2014-02-28 14:10 ` Luiz Augusto von Dentz
2014-03-03 7:15 ` Adam Lee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1393571362-27898-1-git-send-email-adam8157@gmail.com \
--to=adam8157@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=marcel@holtmann.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox