aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@tieto.com>2012-04-13 12:11:42 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2012-04-13 13:21:55 +0300
commit0e6d3c9bbdc19ffa85b9b404d2bb31d8b81b3df0 (patch)
tree4f506abf79b99755cdbe6c92c6e6deddfcb3b442
parentb063ca7c0d2f88a3ee348598b5f3062405fc0406 (diff)
downloadbluez-0e6d3c9bbdc19ffa85b9b404d2bb31d8b81b3df0.tar.gz
bluez-0e6d3c9bbdc19ffa85b9b404d2bb31d8b81b3df0.tar.xz
bluez-0e6d3c9bbdc19ffa85b9b404d2bb31d8b81b3df0.zip
sdp-client: Add ability to clear cached session
This will be usefull for disconnecting SDP L2CAP channel before cached session timeout fires.
-rw-r--r--src/sdp-client.c22
-rw-r--r--src/sdp-client.h1
2 files changed, 22 insertions, 1 deletions
diff --git a/src/sdp-client.c b/src/sdp-client.c
index 3e78dde1..55e59c27 100644
--- a/src/sdp-client.c
+++ b/src/sdp-client.c
@@ -61,7 +61,7 @@ static gboolean cached_session_expired(gpointer user_data)
return FALSE;
}
-static sdp_session_t *get_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;
@@ -82,6 +82,17 @@ static sdp_session_t *get_sdp_session(const bdaddr_t *src, const bdaddr_t *dst)
return session;
}
+ return NULL;
+}
+
+static sdp_session_t *get_sdp_session(const bdaddr_t *src, const bdaddr_t *dst)
+{
+ sdp_session_t *session;
+
+ session = get_cached_sdp_session(src, dst);
+ if (session)
+ return session;
+
return sdp_connect(src, dst, SDP_NON_BLOCKING);
}
@@ -366,3 +377,12 @@ int bt_cancel_discovery(const bdaddr_t *src, const bdaddr_t *dst)
return 0;
}
+
+void bt_clear_cached_session(const bdaddr_t *src, const bdaddr_t *dst)
+{
+ sdp_session_t *session;
+
+ session = get_cached_sdp_session(src, dst);
+ if (session)
+ sdp_close(session);
+}
diff --git a/src/sdp-client.h b/src/sdp-client.h
index 13d91216..91915941 100644
--- a/src/sdp-client.h
+++ b/src/sdp-client.h
@@ -28,3 +28,4 @@ int bt_search_service(const bdaddr_t *src, const bdaddr_t *dst,
uuid_t *uuid, bt_callback_t cb, void *user_data,
bt_destroy_t destroy);
int bt_cancel_discovery(const bdaddr_t *src, const bdaddr_t *dst);
+void bt_clear_cached_session(const bdaddr_t *src, const bdaddr_t *dst);