The forthcoming patch to add Avahi support requires a couple of enhancements
to our event loop to support integration with Avahi's event callback needs
- Ability to update the event mask for a pre-existing file handle watch
- Ability to change the frequency of a timer watch
- Ability to have a timer which fires immediately
- Ability to disable events on a timer watch
The first point was trivial - just change the 'events' flag we have recorded
in the virEventHandle struct.
The second point was also trivial - just change the period of the timer as
recorded in virEventTimer struct.
The last two points were more tricky, but doable. To fire a timer immediately
I tweaked the logic so that it allows a frequency of '0'. Obviously to avoid
spinning 100%, the app should unregister the timer once it has fired the
desired number of times (usually 1). To disable a timer temporarily I allow
the use of '-1' in the frequency.
THe code had a bad mix of terminology using a 'timer' and 'timeout' field
in the virEventTimer struct which confused me no end. So I renamed the
'timeout' field to 'frequency' which reflects its actual purpose.
Finally, when building with debugging, the event loop can generate alot of
data, so I added a EVENT_DEBUG macro to the file which prefixes EVENT: on
all debug output so allow easy filtering.
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules:
http://search.cpan.org/~danberr/ -=|
|=- Projects:
http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|