Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discover function lock release issue #609

Closed
ajcasagrande opened this issue Oct 3, 2020 · 2 comments · Fixed by #624
Closed

Discover function lock release issue #609

ajcasagrande opened this issue Oct 3, 2020 · 2 comments · Fixed by #624
Assignees
Labels
2-medium priority denoting issues with cross-cutting project impact bug Something isn't working hanoi Hanoi release

Comments

@ajcasagrande
Copy link
Contributor

Currently the lock for a currently running discover process is only released when data is sent over the deviceCh.

case devices := <-s.deviceCh:
id := handler.ReleaseLock()

In reality it should be tied to when the discover function completes.

go discovery.Discover()

The reason for this is because the way it is now, the only way to "tell" the SDK that you are done is to send data over that channel, even if it is just nil. If you do not send data on that channel the SDK will assume you are still discovering forever.

On top of that it does not allow the discover process to add devices on-the-fly as they are discovered, otherwise the SDK will incorrectly assume discovery is complete and release the lock. This forces the developer to buffer up the discovered devices and release them as a batch at the end.

@cloudxxx8 cloudxxx8 added 2-medium priority denoting issues with cross-cutting project impact bug Something isn't working hanoi Hanoi release labels Oct 3, 2020
@chr1shung
Copy link

The reason for this is because the way it is now, the only way to "tell" the SDK that you are done is to send data over that channel, even if it is just nil. If you do not send data on that channel the SDK will assume you are still discovering forever.

202 indicates discovery has been triggered or is already running. Back during I was implementing this, in my opinion whenever there's something return from Discovery (i.e. sent back to channel) we can continue trigger another discovery process.

On top of that it does not allow the discover process to add devices on-the-fly as they are discovered, otherwise the SDK will incorrectly assume discovery is complete and release the lock. This forces the developer to buffer up the discovered devices and release them as a batch at the end.

This do limit the implementation of ProtocolDiscovery to send devices as a batch in one protocol-specific discovery process though.

@lenny-intel @iain-anderson @cloudxxx8 may you share you thought on above topics ?

@iain-anderson
Copy link
Member

I'd be tempted to write a wrapper function that called discovery.Discover() and released the lock when that call had completed.
Then go wrapper, and remove the unlock code from the async handler

chr1shung pushed a commit to chr1shung/device-sdk-go that referenced this issue Oct 8, 2020
Add a wrapper function to call discovery.Discovery() and release the
lock when call completed so that developer will not be forced to push
something to deviceCh to release the lock

fix edgexfoundry#609

Signed-off-by: Chris Hung <chris@iotechsys.com>
chr1shung pushed a commit to chr1shung/device-sdk-go that referenced this issue Oct 8, 2020
Add a wrapper function to call discovery.Discovery() and release the
lock when call completed so that developer will not be forced to push
something to deviceCh to release the lock

fix edgexfoundry#609

Signed-off-by: Chris Hung <chris@iotechsys.com>
chr1shung pushed a commit to chr1shung/device-sdk-go that referenced this issue Oct 8, 2020
Add a wrapper function to call discovery.Discovery() and release the
lock when call completed so that developer will not be forced to push
something to deviceCh to release the lock

fix edgexfoundry#609

Signed-off-by: Chris Hung <chris@iotechsys.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2-medium priority denoting issues with cross-cutting project impact bug Something isn't working hanoi Hanoi release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants