forked from openthread/ot-br-posix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mdns-avahi] handle freed
AvahiWatch/Timeout
entries as processing …
…run loop Avahi provides a mechanism to integrate it to a `select()` style run loop where an implementation can provide an `AvahiWatch` and an `AvahiTimeout` structure along with a set of related APIs (as function pointers given to Avahi client) for it to allocate new watch/timeout entries or update or free them. A watch entry provides a set of events to watch for and expects its given callback to be invoked when the events occur. A timeout provides an abstraction for a timer. This commit updates `AvahiPoller` (which integrates Avahi to run loop as a `MainloopProcessor`) to protect against situations where entries get freed or updated as Avahi callbacks are invoked from `AvahiPoller::Process()`. When we invoke the callback for an `AvahiWatch` or `AvahiTimeout` the Avahi module can call any of APIs we provided to it. For example, it can update or free any existing `AvahiWatch/Timeout` entry, which in turn, modifies the `mWatches` or `mTimers` list being tracked by the `AvahiPoller`. This commit updates the `AvahiPoller` class to correctly handle such situations. Before invoking the callback, we update the entry's state and after returning from callback we restart the iteration over the watch/timer list to find the next entry to report, as the list may have changed during execution of the callback.
- Loading branch information
Showing
1 changed file
with
112 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters