-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
[WIP] IP Add-on Finder: make scans asynchronously #4094
base: main
Are you sure you want to change the base?
[WIP] IP Add-on Finder: make scans asynchronously #4094
Conversation
93d333b
to
ff624d2
Compare
@andrewfg DCO check does not allow putting you as the main author when I submit the change, I changed Author and Co-Author to make it pass. |
There are some technical questions not yet clarified, e.g. how to make sure that discovery of different add-ons at the same time does not cause problems. Just imagine two add-ons using the same server port, etc... And the implementation before had a 20sec timeout to avoid hick-ups during OH start (when the xml is parsed, I will have a look into this the next days. |
It is not that likely, but you are right that we need to plan for the worst. The current scan task comprises a sender and a listener. I'm not 100% sure if the socket code requires exclusive send/receive access on a port (in which case a second task on the same port would fail due to an access violation), or if it re-uses sockets (SO_REUSE..) (in which case there could be crosstalk between data from two tasks).
The code cancels prior tasks before initiating new ones. I think the only issue would be if a cancelled task had not yet fully completed being cancelled by the time a new task for the same port would be started. In that case the issue becomes exactly the same as the issue above (two tasks trying to access the same port). However this issue could be resolved if stopScanJobs() would wait for cancelled futures to actually complete. Note the cancel call is with allowInterrupt so it should interrupt the normal socket timeout on not yet completed tasks, so this should complete fast enough. |
@holgerfriedrich the following code shows how I would synchronise multiple tasks to wait for (say) the same listening port (not tested)..
@holgerfriedrich the following code shows how to make stopScanJobs() wait until all tasks have been cancelled (not tested)..
|
1eaa4a1
to
9a1f9e8
Compare
I would still urge to implement limiting the number of interfaces being used, similar to what is now done in #4036. |
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de> Co-autored-by: Andrew Fiddian-Green <software@whitebear.ch>
9a1f9e8
to
8bc206d
Compare
Currently, the IP Add-on Finder scans sequentially: binding by binding, interface by interface.
This PR implements scanning in an asynchronous way.
Refs: #3936
Initial PR implementation is by @andrewfg, as mentioned in #3943 (comment), thanks!
This is WIP, we can discuss further improvements in this PR.