On Mon, Dec 26, 2022 at 01:11:22PM +0100, Marc Lehmann wrote:
> On Sun, Dec 25, 2022 at 09:09:26PM -0800, Michael Stein <m...@zlvfc.com> 
> wrote:
> > So I'm not sure when anyone would use ev_io_modify....
> 
> The documentatioon explains it: it is faster with some backends (e.g.
> epoll) because the file description is assumed to change. When using
> ev_io_Set, libev assumes that the file description might have changed.
> 
> > When io_cb gets control it has nothing to send so it uses ev_io_modify
> > to turn off EV_WRITE:
> 
> Did you stop the watcher before calling ev_io_modify?

No, to my dismay I did not. From man ev:

 As long as your watcher is active (has been started but not stopped)
 you must not touch the values stored in it except when explicitly
 documented otherwise.

I'm new to libev and I see now that to support the various backends it
has to require the watcher be stopped for any modification (other than
the callback address).

I was thinking of the parameters to poll and how when not in poll the
struct pollfd values are free to be modified before the next poll call.

Also, in my mind, I wrongly considered that I wasn't touching the watcher,
I pictured the ev_io_modify call was changing things.

Thank you, it's all clear now.

PS: I wonder if there is any code out there using libev which is
    doing what I was doing and not noticing the 100% CPU...



_______________________________________________
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev

Reply via email to