diff mbox series

[BlueZ,6/8] device: Handle error from discover services request after pair

Message ID 20230725084431.640332-7-simon.mikuda@streamunlimited.com (mailing list archive)
State New, archived
Headers show
Series Various fixes and refactors | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch warning WARNING:TYPO_SPELLING: 'successfull' may be misspelled - perhaps 'successful'? #80: If discovery was requesed from pair request we will report successfull ^^^^^^^^^^^ WARNING:LONG_LINE: line length of 82 exceeds 80 columns #104: FILE: src/device.c:6362: + err = device_discover_services(device, bdaddr_type, bonding->msg); WARNING:LONG_LINE: line length of 85 exceeds 80 columns #107: FILE: src/device.c:6365: + g_dbus_emit_property_changed(dbus_conn, device->path, WARNING:LONG_LINE: line length of 86 exceeds 80 columns #112: FILE: src/device.c:6370: + g_dbus_send_reply(dbus_conn, bonding->msg, DBUS_TYPE_INVALID); /github/workspace/src/src/13326124.patch total: 0 errors, 4 warnings, 25 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/13326124.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

Commit Message

Simon Mikuda July 25, 2023, 8:44 a.m. UTC
If discovery was requesed from pair request we will report successfull
pairing even if there was an error during discovery.
---
 src/device.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Luiz Augusto von Dentz July 27, 2023, 6:46 p.m. UTC | #1
Hi Simon,

On Tue, Jul 25, 2023 at 1:56 AM Simon Mikuda
<simon.mikuda@streamunlimited.com> wrote:
>
> If discovery was requesed from pair request we will report successfull
> pairing even if there was an error during discovery.
> ---
>  src/device.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/src/device.c b/src/device.c
> index 446e978ee..35c46e451 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -6309,6 +6309,7 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type,
>         struct bonding_req *bonding = device->bonding;
>         struct authentication_req *auth = device->authr;
>         struct bearer_state *state = get_state(device, bdaddr_type);
> +       int err;
>
>         DBG("bonding %p status 0x%02x", bonding, status);
>
> @@ -6358,8 +6359,16 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type,
>                 DBG("Proceeding with service discovery");
>                 /* If we are initiators remove any discovery timer and just
>                  * start discovering services directly */
> -               device_discover_services(device, bdaddr_type, bonding->msg);
> -
> +               err = device_discover_services(device, bdaddr_type, bonding->msg);
> +               if (err) {
> +                       if (device->pending_paired) {
> +                               g_dbus_emit_property_changed(dbus_conn, device->path,
> +                                               DEVICE_INTERFACE, "Paired");
> +                               device->pending_paired = false;
> +                       }
> +                       /* Disregard browse errors in case of Pair */
> +                       g_dbus_send_reply(dbus_conn, bonding->msg, DBUS_TYPE_INVALID);
> +               }
>                 bonding_request_free(bonding);
>         } else if (!state->svc_resolved) {
>                 if (!device->browse && !device->discov_timer &&
> --
> 2.34.1

This looks like a fix so I'd recommend sending it separately rewording
the commit to something like: device: Fix returning discovery error
for Device.Pair...
diff mbox series

Patch

diff --git a/src/device.c b/src/device.c
index 446e978ee..35c46e451 100644
--- a/src/device.c
+++ b/src/device.c
@@ -6309,6 +6309,7 @@  void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type,
 	struct bonding_req *bonding = device->bonding;
 	struct authentication_req *auth = device->authr;
 	struct bearer_state *state = get_state(device, bdaddr_type);
+	int err;
 
 	DBG("bonding %p status 0x%02x", bonding, status);
 
@@ -6358,8 +6359,16 @@  void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type,
 		DBG("Proceeding with service discovery");
 		/* If we are initiators remove any discovery timer and just
 		 * start discovering services directly */
-		device_discover_services(device, bdaddr_type, bonding->msg);
-
+		err = device_discover_services(device, bdaddr_type, bonding->msg);
+		if (err) {
+			if (device->pending_paired) {
+				g_dbus_emit_property_changed(dbus_conn, device->path,
+						DEVICE_INTERFACE, "Paired");
+				device->pending_paired = false;
+			}
+			/* Disregard browse errors in case of Pair */
+			g_dbus_send_reply(dbus_conn, bonding->msg, DBUS_TYPE_INVALID);
+		}
 		bonding_request_free(bonding);
 	} else if (!state->svc_resolved) {
 		if (!device->browse && !device->discov_timer &&