summaryrefslogtreecommitdiffstats
path: root/common/glib-helper.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-06-16 16:56:38 +0000
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-06-16 16:56:38 +0000
commit289e29c6c4a073569c7e7aa3c8fc51ed5c46993f (patch)
tree805cb9c598279c9a556d9f9410a119a84ca6d11b /common/glib-helper.c
parent1e4c95e09bf53e50ad033febae0d6383517508b4 (diff)
Fix bt_cancel_discovery to only succeed when there is a discover to cancel.
Diffstat (limited to 'common/glib-helper.c')
-rw-r--r--common/glib-helper.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/common/glib-helper.c b/common/glib-helper.c
index ed203eb4..eab30b5e 100644
--- a/common/glib-helper.c
+++ b/common/glib-helper.c
@@ -314,7 +314,7 @@ static int find_by_bdaddr(const void *data, const void *user_data)
bacmp(&ctxt->src, &search->src));
}
-void bt_cancel_discovery(const bdaddr_t *src, const bdaddr_t *dst)
+int bt_cancel_discovery(const bdaddr_t *src, const bdaddr_t *dst)
{
struct search_context search, *ctxt;
GSList *match;
@@ -323,14 +323,17 @@ void bt_cancel_discovery(const bdaddr_t *src, const bdaddr_t *dst)
bacpy(&search.src, src);
bacpy(&search.dst, dst);
+ /* Ongoing SDP Discovery */
match = g_slist_find_custom(context_list, &search, find_by_bdaddr);
+ if (!match)
+ return -ENODATA;
- /* Ongoing SDP Discovery */
- if (match) {
- ctxt = match->data;
- if (ctxt->session)
- close(ctxt->session->sock);
- }
+ ctxt = match->data;
+ if (!ctxt->session)
+ return -ENOTCONN;
+
+ close(ctxt->session->sock);
+ return 0;
}
char *bt_uuid2string(uuid_t *uuid)