diff mbox series

[BlueZ,v2] policy: Fix service retry counters reset

Message ID 20250527134521.4942-1-repk@triplefau.lt
State New
Headers show
Series [BlueZ,v2] policy: Fix service retry counters reset | expand

Commit Message

Remi Pommarel May 27, 2025, 1:45 p.m. UTC
Control and Target retries counter were reset when service state
goes from CONNECTED to DISCONNECTED, but usually an extra DISCONNECTING
state is reached before going to DISCONNECTED. This causes retry counter
to not being reset in this case, leading to service not being able to
initialize on next connection. Source, sink and HS retry counter were
only reset when limit was reached, moreover HS timer was not removed on
CONNECTED state.

Reset all service retry counter as soon as CONNECTED state is reached to
avoid that. Also remove hs timer to match other services.
---
Changes since v1:
  - Reset all service retry counter on CONNECTED
  - Remove hs_timer on CONNECTED
---
 plugins/policy.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

bluez.test.bot@gmail.com May 27, 2025, 3:28 p.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=966680

---Test result---

Test Summary:
CheckPatch                    PENDING   0.24 seconds
GitLint                       PENDING   0.25 seconds
BuildEll                      PASS      20.09 seconds
BluezMake                     PASS      2671.38 seconds
MakeCheck                     PASS      19.82 seconds
MakeDistcheck                 PASS      197.54 seconds
CheckValgrind                 PASS      272.85 seconds
CheckSmatch                   PASS      301.32 seconds
bluezmakeextell               PASS      126.57 seconds
IncrementalBuild              PENDING   0.37 seconds
ScanBuild                     PASS      895.61 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth
patchwork-bot+bluetooth@kernel.org May 27, 2025, 9:20 p.m. UTC | #2
Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue, 27 May 2025 15:45:21 +0200 you wrote:
> Control and Target retries counter were reset when service state
> goes from CONNECTED to DISCONNECTED, but usually an extra DISCONNECTING
> state is reached before going to DISCONNECTED. This causes retry counter
> to not being reset in this case, leading to service not being able to
> initialize on next connection. Source, sink and HS retry counter were
> only reset when limit was reached, moreover HS timer was not removed on
> CONNECTED state.
> 
> [...]

Here is the summary with links:
  - [BlueZ,v2] policy: Fix service retry counters reset
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=2a552b93de8b

You are awesome, thank you!
diff mbox series

Patch

diff --git a/plugins/policy.c b/plugins/policy.c
index 0e533ba1f..561e3c089 100644
--- a/plugins/policy.c
+++ b/plugins/policy.c
@@ -311,6 +311,7 @@  static void sink_cb(struct btd_service *service, btd_service_state_t old_state,
 			timeout_remove(data->sink_timer);
 			data->sink_timer = 0;
 		}
+		data->sink_retries = 0;
 
 		/* Try connecting HSP/HFP if it is not connected */
 		hs = btd_device_get_service(dev, HFP_HS_UUID);
@@ -375,6 +376,11 @@  static void hs_cb(struct btd_service *service, btd_service_state_t old_state,
 	case BTD_SERVICE_STATE_CONNECTING:
 		break;
 	case BTD_SERVICE_STATE_CONNECTED:
+		if (data->hs_timer > 0) {
+			timeout_remove(data->hs_timer);
+			data->hs_timer = 0;
+		}
+		data->hs_retries = 0;
 		/* Check if service initiate the connection then proceed
 		 * immediately otherwise set timer
 		 */
@@ -489,6 +495,7 @@  static void source_cb(struct btd_service *service,
 			timeout_remove(data->source_timer);
 			data->source_timer = 0;
 		}
+		data->source_retries = 0;
 
 		/* Check if service initiate the connection then proceed
 		 * immediatelly otherwise set timer
@@ -537,8 +544,6 @@  static void controller_cb(struct btd_service *service,
 				timeout_remove(data->ct_timer);
 				data->ct_timer = 0;
 			}
-		} else if (old_state == BTD_SERVICE_STATE_CONNECTED) {
-			data->ct_retries = 0;
 		}
 		break;
 	case BTD_SERVICE_STATE_CONNECTING:
@@ -548,6 +553,7 @@  static void controller_cb(struct btd_service *service,
 			timeout_remove(data->ct_timer);
 			data->ct_timer = 0;
 		}
+		data->ct_retries = 0;
 		break;
 	case BTD_SERVICE_STATE_DISCONNECTING:
 		break;
@@ -587,8 +593,6 @@  static void target_cb(struct btd_service *service,
 				timeout_remove(data->tg_timer);
 				data->tg_timer = 0;
 			}
-		} else if (old_state == BTD_SERVICE_STATE_CONNECTED) {
-			data->tg_retries = 0;
 		}
 		break;
 	case BTD_SERVICE_STATE_CONNECTING:
@@ -598,6 +602,7 @@  static void target_cb(struct btd_service *service,
 			timeout_remove(data->tg_timer);
 			data->tg_timer = 0;
 		}
+		data->tg_retries = 0;
 		break;
 	case BTD_SERVICE_STATE_DISCONNECTING:
 		break;