Message ID | 20240912092253.119754-3-hadess@hadess.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fix bluetoothctl hanging if daemon isn't running | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | success | Success |
tedd_an/CheckPatch | warning | WARNING:LONG_LINE: line length of 83 exceeds 80 columns #105: FILE: client/main.c:3237: + timeout_id = timeout_add(timeout * 1000, timeout_quit, NULL, NULL); /github/workspace/src/src/13801792.patch total: 0 errors, 1 warnings, 47 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. /github/workspace/src/src/13801792.patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. |
tedd_an/GitLint | success | Gitlint PASS |
tedd_an/IncrementalBuild | success | Incremental Build PASS |
diff --git a/client/main.c b/client/main.c index a96a4263849d..8791466e49ff 100644 --- a/client/main.c +++ b/client/main.c @@ -22,7 +22,9 @@ #include <glib.h> +#include "src/shared/mainloop.h" #include "src/shared/shell.h" +#include "src/shared/timeout.h" #include "src/shared/util.h" #include "src/shared/ad.h" #include "gdbus/gdbus.h" @@ -3173,13 +3175,25 @@ static const struct bt_shell_opt opt = { static void client_ready(GDBusClient *client, void *user_data) { + unsigned int *timeout_id = user_data; + + if (*timeout_id > 0) + timeout_remove(*timeout_id); setup_standard_input(); } +static bool timeout_quit(void *user_data) +{ + mainloop_exit_failure(); + return true; +} + int main(int argc, char *argv[]) { GDBusClient *client; int status; + int timeout; + unsigned int timeout_id; bt_shell_init(argc, argv, &opt); bt_shell_set_menu(&main_menu); @@ -3217,8 +3231,11 @@ int main(int argc, char *argv[]) g_dbus_client_set_proxy_handlers(client, proxy_added, proxy_removed, property_changed, NULL); - g_dbus_client_set_ready_watch(client, client_ready, NULL); - + timeout = bt_shell_get_timeout(); + timeout_id = 0; + if (timeout > 0) + timeout_id = timeout_add(timeout * 1000, timeout_quit, NULL, NULL); + g_dbus_client_set_ready_watch(client, client_ready, &timeout_id); status = bt_shell_run(); admin_remove_submenu();