I'm using libev
for watching FD events, but sometimes I need to close the underlying FD.
Therefore, I'm stopping the IO watcher (by calling its stop
function), but it seems not enough, as I'm still getting this error after calling close(fd)
:
ev_epoll.c:134: epoll_modify: Assertion `("libev: I/O watcher with invalid fd found in epoll_ctl", errno != EBADF && errno != ELOOP && errno != EINVAL)' failed.
How can I make sure to solve this error, if I don't want to delete the ev_loop
as it still needs to watch other changes?
It seems, an IO-watcher added to ev_loop must always have to have a valid (opened) FD, even if it's stopped. Or am I doing something wrong?
myEVLoop = ev_loop_new(0);
myEVIO.stop();
myEVIO.set<MyClass, &MyClass::myRead>(this);
myEVIO.set(myEVLoop);
//... (some other ios and timers, and asyncs)
myEVIO.set(fd, ev::READ);
myEVIO.start();
IN THREAD1: ev_run(myEVLoop, 0);
IN THREAD2: myEVIO.stop(); close(fd);
After this close
call the above error comes. Can I somehow conquer this?