On Tue, 2005-07-12 at 16:07 +0100, Dominic Marks wrote:
io_loop_handle_remove() should always be called before close(), so kevent() should never fail. What am I missing?
Seems to be the other way around, since I can work around the warning by using fstat to check if the descriptor is in use. I currently have this:
if (kevent(data->kq, &data->event, 1, NULL, 0, NULL) < 0) { if (fstat(fd, NULL) == 0) { /* * Trying to remove filters on a closed descriptor * will cause kevent(2) to return an error. If we * sure that descriptors are ALWAYS closed before * this function we can delete the entire function * body. */ i_warning("couldn't remove filter on fd %d with kqueue: %m", fd); }
Uhm. I think Dovecot's code should rather be fixed so the function doesn't get called with closed file descriptors. I'm not sure if it's possible everywhere without larger changes though..
Anyway I don't think you should add the extra fstat() there, not giving a warning if EBADF error comes is just as good without extra syscall.