aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Schink <jaylink-dev@marcschink.de>2017-08-22 21:07:39 +0200
committerMarc Schink <jaylink-dev@marcschink.de>2017-08-22 21:52:00 +0200
commit600117cca0bbd02ccfb6c02547c93817036a2243 (patch)
treeddd0c219c25d95b5321814982593dbb9dd0979cc
parent8c67221bb7f7a606b828d08c8c873299fcf2db1a (diff)
discovery/tcp: Ignore already discovered devices
Signed-off-by: Marc Schink <jaylink-dev@marcschink.de>
-rw-r--r--libjaylink/discovery_tcp.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/libjaylink/discovery_tcp.c b/libjaylink/discovery_tcp.c
index 555e121..002fa67 100644
--- a/libjaylink/discovery_tcp.c
+++ b/libjaylink/discovery_tcp.c
@@ -96,12 +96,12 @@ static bool compare_devices(const void *a, const void *b)
return true;
}
-static struct jaylink_device *find_device(const struct jaylink_context *ctx,
+static struct jaylink_device *find_device(struct list *list,
const struct jaylink_device *dev)
{
struct list *item;
- item = list_find_custom(ctx->devs, &compare_devices, dev);
+ item = list_find_custom(list, &compare_devices, dev);
if (item)
return item->data;
@@ -179,7 +179,14 @@ static struct jaylink_device *probe_device(struct jaylink_context *ctx,
if (tmp.has_nickname)
log_dbg(ctx, "Device: Nickname = %s.", tmp.nickname);
- dev = find_device(ctx, &tmp);
+ dev = find_device(ctx->discovered_devs, &tmp);
+
+ if (dev) {
+ log_dbg(ctx, "Ignoring already discovered device.");
+ return NULL;
+ }
+
+ dev = find_device(ctx->devs, &tmp);
if (dev) {
log_dbg(ctx, "Using existing device instance.");