On Thu, Apr 24, 2014 at 11:30:09AM +0300, Assaf Inbal <shmuel...@gmail.com> 
wrote:
> I'm using libev as a part of a larger project. In this project I have a
> library that does some asynchronous work directly over FDs and timers.
> While I understand that it's not exactly recommended, these FDs can also be
> of local files as well as sockets.

It's not so much not recommended, but it makes no sense - the fact that
you use "asynchronous" (no, it's not asynchronous) and O_NONBLOCK (has
no effect on file I/O) for file I/O seems to indicate that you think
that nonblocking I/O on files is somehow asynchronous or different from
blocking I/O.

The reason why libev supports files is to simplify programs that read e.g.
from pipes/stdin, which makes them fall back gracefully to blocking file
I/O.

All that explicitly using files with I/O watchers does is make your
program more complex and slower - libev simply calls your callback on
every iteration when it detects that you are using a file.

> I also tried to locally compile 4.15 but the issue reproduced there as well
> (assuming I did so correctly).

I can't see anything obviously wrong with your program, and can't try it out
right now (but will do so later).

Does it only fail with the epoll backend? (try running with LIBEV_FLAGS=2
in your environment to test) - it could be a bug in the code that
generates fake events for files.

If, as I suspect from your program, you deliberately use watchers for file
descriptors that are known files the fix or workaround is easy though:
just do your I/O directly, that's faster and simpler.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schm...@schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\

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

Reply via email to