closing fd while in loop

Nicolas Van Eenaeme nicolas at massivemedia.eu
Sun Mar 2 20:27:53 CET 2014


Hi Marc,

Do we need to stop the watchers before closing the fd, or the way around?
Since in the documentation it says for EVBACKEND_EPOLL:

"Best performance from this backend is achieved by not unregistering all
watchers for a file descriptor until it has been closed, if possible, i.e.
keep at least one watcher active per fd at all times. Stopping and starting
a watcher (without re-setting it) also usually doesn't cause extra
overhead. A fork can both result in spurious notifications as well as in
libev having to destroy and recreate the epoll object, which can take
considerable time and thus should be avoided."

Or doesn't it make that much difference?

Thanks a lot!

Regards,
Nicolas

2014-03-01 21:38 GMT+01:00 Marc Lehmann <schmorp at schmorp.de>:

> On Sat, Mar 01, 2014 at 07:04:40PM +0330, Jafar habibi livar <
> iceberg.90427 at gmail.com> wrote:
> > if i close fd while the watcher is registered in a loop, will libev stop
> > the watcher or should I do it manually?
>
> You need to stop all watchers for the fd before closing the fd.
>
> --
>                 The choice of a       Deliantra, the free code+content
> MORPG
>       -----==-     _GNU_              http://www.deliantra.net
>       ----==-- _       generation
>       ---==---(_)__  __ ____  __      Marc Lehmann
>       --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
>       -=====/_/_//_/\_,_/ /_/\_\
>
> _______________________________________________
> libev mailing list
> libev at lists.schmorp.de
> http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20140302/0829a25c/attachment.html>


More information about the libev mailing list