* [PATCH 0/3] Fix for sdp-client in reconnect scenario
@ 2014-09-09 9:02 Lukasz Rymanowski
2014-09-09 9:02 ` [PATCH 1/3] sdp-client: Extract cleanup function for cached session Lukasz Rymanowski
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Lukasz Rymanowski @ 2014-09-09 9:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
This patch fixes following error scenario:
1. Local device does sdp search and cache sdp session.
2. Peer device disconnect and connect again
3. Local device wants to do sdp search again on outdated sdp session
If those 3 steps will happen withing 2 sec, we face the issue.
Those patch fixes that.
Automated test which easly triggers that will come from Jakub.
(Hid Host reconnect test)
Lukasz Rymanowski (3):
sdp-client: Extract cleanup function for cached session
sdp-client: Add disconnect watch for cached session
sdp-client: Minor code style fix
src/sdp-client.c | 39 +++++++++++++++++++++++++++++++++------
1 file changed, 33 insertions(+), 6 deletions(-)
--
1.8.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] sdp-client: Extract cleanup function for cached session
2014-09-09 9:02 [PATCH 0/3] Fix for sdp-client in reconnect scenario Lukasz Rymanowski
@ 2014-09-09 9:02 ` Lukasz Rymanowski
2014-09-09 9:02 ` [PATCH 2/3] sdp-client: Add disconnect watch " Lukasz Rymanowski
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Lukasz Rymanowski @ 2014-09-09 9:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
Cleanup function will be used by next patch
---
src/sdp-client.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/sdp-client.c b/src/sdp-client.c
index edbdaec..b6a3663 100644
--- a/src/sdp-client.c
+++ b/src/sdp-client.c
@@ -49,15 +49,18 @@ struct cached_sdp_session {
static GSList *cached_sdp_sessions = NULL;
-static gboolean cached_session_expired(gpointer user_data)
+static void cleanup_cached_session(struct cached_sdp_session *cached)
{
- struct cached_sdp_session *cached = user_data;
-
cached_sdp_sessions = g_slist_remove(cached_sdp_sessions, cached);
-
sdp_close(cached->session);
-
g_free(cached);
+}
+
+static gboolean cached_session_expired(gpointer user_data)
+{
+ struct cached_sdp_session *cached = user_data;
+
+ cleanup_cached_session(cached);
return FALSE;
}
--
1.8.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] sdp-client: Add disconnect watch for cached session
2014-09-09 9:02 [PATCH 0/3] Fix for sdp-client in reconnect scenario Lukasz Rymanowski
2014-09-09 9:02 ` [PATCH 1/3] sdp-client: Extract cleanup function for cached session Lukasz Rymanowski
@ 2014-09-09 9:02 ` Lukasz Rymanowski
2014-09-09 9:02 ` [PATCH 3/3] sdp-client: Minor code style fix Lukasz Rymanowski
2014-09-09 23:32 ` [PATCH 0/3] Fix for sdp-client in reconnect scenario Johan Hedberg
3 siblings, 0 replies; 5+ messages in thread
From: Lukasz Rymanowski @ 2014-09-09 9:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
SDP client keeps sdp session alive for 2 more second after usage in case
there is need for reuse it. However, if ACL is disconnected and
reconnected during that time, sdp session becomes outdated. This patch
makes sure that cached sdp session will be cleaned up on ACL disconnect
---
src/sdp-client.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/src/sdp-client.c b/src/sdp-client.c
index b6a3663..f9412f0 100644
--- a/src/sdp-client.c
+++ b/src/sdp-client.c
@@ -45,6 +45,7 @@ struct cached_sdp_session {
bdaddr_t dst;
sdp_session_t *session;
guint timer;
+ guint io_id;
};
static GSList *cached_sdp_sessions = NULL;
@@ -60,6 +61,7 @@ static gboolean cached_session_expired(gpointer user_data)
{
struct cached_sdp_session *cached = user_data;
+ g_source_remove(cached->io_id);
cleanup_cached_session(cached);
return FALSE;
@@ -77,6 +79,7 @@ static sdp_session_t *get_cached_sdp_session(const bdaddr_t *src, const bdaddr_t
continue;
g_source_remove(c->timer);
+ g_source_remove(c->io_id);
session = c->session;
@@ -89,10 +92,23 @@ static sdp_session_t *get_cached_sdp_session(const bdaddr_t *src, const bdaddr_t
return NULL;
}
+static gboolean disconnect_watch(GIOChannel *chan, GIOCondition cond,
+ gpointer user_data)
+{
+ struct cached_sdp_session *cached = user_data;
+
+ g_source_remove(cached->timer);
+ cleanup_cached_session(cached);
+
+ return FALSE;
+}
+
static void cache_sdp_session(bdaddr_t *src, bdaddr_t *dst,
sdp_session_t *session)
{
struct cached_sdp_session *cached;
+ int sk;
+ GIOChannel *chan;
cached = g_new0(struct cached_sdp_session, 1);
@@ -106,6 +122,13 @@ static void cache_sdp_session(bdaddr_t *src, bdaddr_t *dst,
cached->timer = g_timeout_add_seconds(CACHE_TIMEOUT,
cached_session_expired,
cached);
+
+ /* Watch the connection state during cache timeout */
+ sk = sdp_get_socket(session);
+ chan = g_io_channel_unix_new(sk);
+
+ cached->io_id = g_io_add_watch(chan, G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ disconnect_watch, cached);
}
struct search_context {
--
1.8.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] sdp-client: Minor code style fix
2014-09-09 9:02 [PATCH 0/3] Fix for sdp-client in reconnect scenario Lukasz Rymanowski
2014-09-09 9:02 ` [PATCH 1/3] sdp-client: Extract cleanup function for cached session Lukasz Rymanowski
2014-09-09 9:02 ` [PATCH 2/3] sdp-client: Add disconnect watch " Lukasz Rymanowski
@ 2014-09-09 9:02 ` Lukasz Rymanowski
2014-09-09 23:32 ` [PATCH 0/3] Fix for sdp-client in reconnect scenario Johan Hedberg
3 siblings, 0 replies; 5+ messages in thread
From: Lukasz Rymanowski @ 2014-09-09 9:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
---
src/sdp-client.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/sdp-client.c b/src/sdp-client.c
index f9412f0..fbe266e 100644
--- a/src/sdp-client.c
+++ b/src/sdp-client.c
@@ -67,7 +67,8 @@ static gboolean cached_session_expired(gpointer user_data)
return FALSE;
}
-static sdp_session_t *get_cached_sdp_session(const bdaddr_t *src, const bdaddr_t *dst)
+static sdp_session_t *get_cached_sdp_session(const bdaddr_t *src,
+ const bdaddr_t *dst)
{
GSList *l;
--
1.8.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] Fix for sdp-client in reconnect scenario
2014-09-09 9:02 [PATCH 0/3] Fix for sdp-client in reconnect scenario Lukasz Rymanowski
` (2 preceding siblings ...)
2014-09-09 9:02 ` [PATCH 3/3] sdp-client: Minor code style fix Lukasz Rymanowski
@ 2014-09-09 23:32 ` Johan Hedberg
3 siblings, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2014-09-09 23:32 UTC (permalink / raw)
To: Lukasz Rymanowski; +Cc: linux-bluetooth
Hi Lukasz,
On Tue, Sep 09, 2014, Lukasz Rymanowski wrote:
> This patch fixes following error scenario:
> 1. Local device does sdp search and cache sdp session.
> 2. Peer device disconnect and connect again
> 3. Local device wants to do sdp search again on outdated sdp session
>
> If those 3 steps will happen withing 2 sec, we face the issue.
>
> Those patch fixes that.
> Automated test which easly triggers that will come from Jakub.
> (Hid Host reconnect test)
>
> Lukasz Rymanowski (3):
> sdp-client: Extract cleanup function for cached session
> sdp-client: Add disconnect watch for cached session
> sdp-client: Minor code style fix
>
> src/sdp-client.c | 39 +++++++++++++++++++++++++++++++++------
> 1 file changed, 33 insertions(+), 6 deletions(-)
All three patches have been applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-09-09 23:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-09 9:02 [PATCH 0/3] Fix for sdp-client in reconnect scenario Lukasz Rymanowski
2014-09-09 9:02 ` [PATCH 1/3] sdp-client: Extract cleanup function for cached session Lukasz Rymanowski
2014-09-09 9:02 ` [PATCH 2/3] sdp-client: Add disconnect watch " Lukasz Rymanowski
2014-09-09 9:02 ` [PATCH 3/3] sdp-client: Minor code style fix Lukasz Rymanowski
2014-09-09 23:32 ` [PATCH 0/3] Fix for sdp-client in reconnect scenario Johan Hedberg
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).