lib/discovery: Prevent plugins from stomping on each other.

Prior to this commit, when multiple plugins are used for discovery then
events from one could stomp those from the other. For example, consider
two devices that have both mDNS and BLE connectivity to each other.
Services advertised will be picked up on both channels. If they move
out of BLE range (but are still on the same IP network), then the
"Lost" event from the BLE plugin would be delivered to the client which
might then mistakenly determine that the advertisement is no longer
valid (even though the mDNS plugin still sees it).

This commit fixes that by introducing reference counts per-plugin.
"Lost" events are delivered to the client only if *all* plugins that
previously saw an advertisement no longer see it.

The test added in discovery_test.go tests this behavior and fails
without the corresponding changes in scan.go

Change-Id: I455ba4c0b7c3211e2b8db84c53086a147e1d7587
13 files changed
tree: cb9b08b5f712dc5e9f52d3888c12ceeb20128536
  1. cmd/
  2. examples/
  3. internal/
  4. lib/
  5. runtime/
  6. services/
  7. test/
  8. .gitignore
  9. AUTHORS
  10. CONTRIBUTING.md
  11. CONTRIBUTORS
  12. envvar.go
  13. envvar_test.go
  14. LICENSE
  15. PATENTS
  16. README.md
  17. VERSION
README.md

Vanadium

This repository contains a reference implementation of the Vanadium APIs.

Unlike the APIs in https://github.com/vanadium/go.v23, which promises to provide backward compatibility this repository makes no such promises.