* [PATCH BlueZ] core/profile: Fix calling service_accept
@ 2016-10-24 16:32 Luiz Augusto von Dentz
2016-10-24 19:19 ` Szymon Janc
0 siblings, 1 reply; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2016-10-24 16:32 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
service_accept shall only be used with profiles that implement .accept
callback, to set connecting state directly use service_set_connecting
which does not require .accept to be implemented.
---
src/profile.c | 2 +-
src/service.c | 19 +++++++++++++++++++
src/service.h | 1 +
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/profile.c b/src/profile.c
index c81a9f9..7c5318c 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -1047,7 +1047,7 @@ static void ext_connect(GIOChannel *io, GError *err, gpointer user_data)
conn);
}
- if (conn->service && service_accept(conn->service) < 0)
+ if (conn->service && service_set_connecting(conn->service) < 0)
goto drop;
if (send_new_connection(ext, conn))
diff --git a/src/service.c b/src/service.c
index 20a41d0..207ffae 100644
--- a/src/service.c
+++ b/src/service.c
@@ -214,6 +214,25 @@ done:
return 0;
}
+int service_set_connecting(struct btd_service *service)
+{
+ switch (service->state) {
+ case BTD_SERVICE_STATE_UNAVAILABLE:
+ return -EINVAL;
+ case BTD_SERVICE_STATE_DISCONNECTED:
+ break;
+ case BTD_SERVICE_STATE_CONNECTING:
+ case BTD_SERVICE_STATE_CONNECTED:
+ return 0;
+ case BTD_SERVICE_STATE_DISCONNECTING:
+ return -EBUSY;
+ }
+
+ change_state(service, BTD_SERVICE_STATE_CONNECTING, 0);
+
+ return 0;
+}
+
int btd_service_connect(struct btd_service *service)
{
struct btd_profile *profile = service->profile;
diff --git a/src/service.h b/src/service.h
index c1f97f6..6f1edfb 100644
--- a/src/service.h
+++ b/src/service.h
@@ -49,6 +49,7 @@ int service_probe(struct btd_service *service);
void service_remove(struct btd_service *service);
int service_accept(struct btd_service *service);
+int service_set_connecting(struct btd_service *service);
/* Connection control API */
int btd_service_connect(struct btd_service *service);
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH BlueZ] core/profile: Fix calling service_accept
2016-10-24 16:32 [PATCH BlueZ] core/profile: Fix calling service_accept Luiz Augusto von Dentz
@ 2016-10-24 19:19 ` Szymon Janc
0 siblings, 0 replies; 2+ messages in thread
From: Szymon Janc @ 2016-10-24 19:19 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hi Luiz,
On Monday, 24 October 2016 19:32:57 CEST Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> service_accept shall only be used with profiles that implement .accept
> callback, to set connecting state directly use service_set_connecting
> which does not require .accept to be implemented.
> ---
> src/profile.c | 2 +-
> src/service.c | 19 +++++++++++++++++++
> src/service.h | 1 +
> 3 files changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/src/profile.c b/src/profile.c
> index c81a9f9..7c5318c 100644
> --- a/src/profile.c
> +++ b/src/profile.c
> @@ -1047,7 +1047,7 @@ static void ext_connect(GIOChannel *io, GError *err,
> gpointer user_data) conn);
> }
>
> - if (conn->service && service_accept(conn->service) < 0)
> + if (conn->service && service_set_connecting(conn->service) < 0)
> goto drop;
>
> if (send_new_connection(ext, conn))
> diff --git a/src/service.c b/src/service.c
> index 20a41d0..207ffae 100644
> --- a/src/service.c
> +++ b/src/service.c
> @@ -214,6 +214,25 @@ done:
> return 0;
> }
>
> +int service_set_connecting(struct btd_service *service)
> +{
> + switch (service->state) {
> + case BTD_SERVICE_STATE_UNAVAILABLE:
> + return -EINVAL;
> + case BTD_SERVICE_STATE_DISCONNECTED:
> + break;
> + case BTD_SERVICE_STATE_CONNECTING:
> + case BTD_SERVICE_STATE_CONNECTED:
> + return 0;
> + case BTD_SERVICE_STATE_DISCONNECTING:
> + return -EBUSY;
> + }
> +
> + change_state(service, BTD_SERVICE_STATE_CONNECTING, 0);
> +
> + return 0;
> +}
> +
> int btd_service_connect(struct btd_service *service)
> {
> struct btd_profile *profile = service->profile;
> diff --git a/src/service.h b/src/service.h
> index c1f97f6..6f1edfb 100644
> --- a/src/service.h
> +++ b/src/service.h
> @@ -49,6 +49,7 @@ int service_probe(struct btd_service *service);
> void service_remove(struct btd_service *service);
>
> int service_accept(struct btd_service *service);
> +int service_set_connecting(struct btd_service *service);
>
> /* Connection control API */
> int btd_service_connect(struct btd_service *service);
Applied, thanks.
--
pozdrawiam
Szymon Janc
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-10-24 19:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-24 16:32 [PATCH BlueZ] core/profile: Fix calling service_accept Luiz Augusto von Dentz
2016-10-24 19:19 ` Szymon Janc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).