service: Add btd_service_is_initiator
Luiz Augusto von Dentz
maintainerPATCH 1/2 service: Add btd_service_is_initiator
From: Luiz Augusto von Dentz <[email protected]>
Since BTD_SERVICE_STATE_CONNECTING is being used for both initiator and responder case it is no longer possible to use the state distint when the service connection was initiated locally or not, so to fix this a new flag is introduce to track when btd_service_connect has been called.
--- src/service.c | 10 ++++++++++ src/service.h | 1 + 2 files changed, 11 insertions(+)
src/service.c +10 -0
@@ -42,6 +42,7 @@ struct btd_service {btd_service_state_t state;int err;bool is_allowed; +bool initiator; };struct service_state_callback {
@@ -96,6 +97,9 @@ static void change_state(struct btd_service *service, btd_service_state_t state, cb->cb (service, old, state, cb->user_data); } + +if (state ==BTD_SERVICE_STATE_DISCONNECTED ) + service->initiator = false; }struct btd_service *btd_service_ref (struct btd_service *service)
@@ -261,6 +265,7 @@ int btd_service_connect(struct btd_service *service) err = profile->connect (service);if (err ==0 ) { + service->initiator = true;change_state (service,BTD_SERVICE_STATE_CONNECTING ,0 );return 0 ; }
@@ -343,6 +348,11 @@ int btd_service_get_error(const struct btd_service *service)return service->err; } +bool btd_service_is_initiator (const struct btd_service *service) +{ +return service->initiator; +} +unsigned int btd_service_add_state_cb (btd_service_state_cb cb,void *user_data) {struct service_state_callback *state_cb;
src/service.h +1 -0
@@ -47,6 +47,7 @@ struct btd_device *btd_service_get_device(const struct btd_service *service);struct btd_profile *btd_service_get_profile (const struct btd_service *service);btd_service_state_t btd_service_get_state (const struct btd_service *service);int btd_service_get_error (const struct btd_service *service); +bool btd_service_is_initiator (const struct btd_service *service);unsigned int btd_service_add_state_cb (btd_service_state_cb cb,void *user_data);
Signature · 1 line
2.31.1
Luiz Augusto von Dentz
maintainerPATCH 2/2 policy: Use btd_service_is_initiator
From: Luiz Augusto von Dentz <[email protected]>
Instead of using BTD_SERVICE_STATE_CONNECTING use btd_service_is_initiator to determine if the service initiated the connection and then proceed to connect other service immediately.
--- plugins/policy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
plugins/policy.c +3 -3
@@ -279,7 +279,7 @@ static void sink_cb(struct btd_service *service, btd_service_state_t old_state,/* Check if service initiate the connection then proceed * immediatelly otherwise set timer */ -if (old_state ==BTD_SERVICE_STATE_CONNECTING ) +if (btd_service_is_initiator (service))policy_connect (data, controller);else if (btd_service_get_state (controller) !=BTD_SERVICE_STATE_CONNECTED )
@@ -315,7 +315,7 @@ static void hs_cb(struct btd_service *service, btd_service_state_t old_state,/* Check if service initiate the connection then proceed * immediately otherwise set timer */ -if (old_state ==BTD_SERVICE_STATE_CONNECTING ) +if (btd_service_is_initiator (service))policy_connect (data, sink);else if (btd_service_get_state (sink) !=BTD_SERVICE_STATE_CONNECTED )
@@ -430,7 +430,7 @@ static void source_cb(struct btd_service *service,/* Check if service initiate the connection then proceed * immediatelly otherwise set timer */ -if (old_state ==BTD_SERVICE_STATE_CONNECTING ) +if (btd_service_is_initiator (service))policy_connect (data, target);else if (btd_service_get_state (target) !=BTD_SERVICE_STATE_CONNECTED )
Signature · 1 line
2.31.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=548375
---Test result---
Test Summary:
CheckPatch PASS 2.68 seconds GitLint PASS 1.80 seconds Prep - Setup ELL PASS 40.71 seconds Build - Prep PASS 0.46 seconds Build - Configure PASS 7.46 seconds Build - Make PASS 174.81 seconds Make Check PASS 8.77 seconds Make Distcheck PASS 206.27 seconds Build w/ext ELL - Configure PASS 7.46 seconds Build w/ext ELL - Make PASS 164.85 seconds
---
Regards,
Linux Bluetooth