-
Notifications
You must be signed in to change notification settings - Fork 134
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
[mdns]: Prevent deadlock when deleting a browse request (IDFGH-13947) #676
[mdns]: Prevent deadlock when deleting a browse request (IDFGH-13947) #676
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
@gytxxsy PTAL, too |
I think this is a necessary fix. However, I noticed some behavior changes introduced by the modification. For example, in the API
Throughout this process, the mdns lock is not acquired by the task. I'm not sure if this behavior could potentially cause some issues. |
I must admit that I do not fully overview the architecture of the mdns component, but the |
No issues here, we're just freeing some local data (which weren't posted to the action queue) on exit path.
Agree. @gytxxsy Thanks for the comments! |
Description
With v1.3.0 the mDNS component supports continuous browsing for services by calling
mdns_browse_new()
. In v1.4.0 whenever one wants to stop browsing for a specific service viamdns_browse_delete()
there is a deadlock resulting in underlying mdns task to block forever, caused by the API locking introduced with the "Fix API race" commits for v1.4.0.Background:
API requests are generally serialized into the mdns task - this also applies to the
mdns_browse_...
calls. The request to stop browsing for a service is put into the mdns task queue and is actually handled by the task via_mdns_execute_action()
->_mdns_browse_finish()
. There it performs a linear search through the queue of pending browse requests to find a matching mDNS service/protocol tuple. Upon match it deletes the item via_mdns_browse_item_free()
what callsmdns_query_results_free()
. The latter is a public API call that tries to acquire the lock semaphore. Unfortunately the initial call to_mdns_execute_action()
in the mdns task is already within a locked section. So in result themdns_query_results_free()
method waits endlessly for the semaphore getting released.Checklist
Before submitting a Pull Request, please ensure the following:
Documentation is updated as needed.(no functional change)Tests are updated or added as necessary.(no functional change)