Re: kevent has bug?

From: Konstantin Belousov <kostikbel_at_gmail.com>
Date: Thu, 3 Apr 2014 16:48:14 +0300
On Thu, Apr 03, 2014 at 06:26:56PM +0900, Kohji Okuno wrote:
> > The done_ev_add case is indeed missed in my patch, thank you for noting.
> > The case of EV_ADD does not need the KN_SCAN workaround, IMO, since the
> > race is possible just by the nature of adding the knote.

> I think, we should add KN_SCAN after knote_attach() in
> kqueue_register(), too. What do you think about this?
See above, I noted this case in the previous mail.  This may be elaborated.

First, I think it is technically incorrect to allow the event
notification before the f_attach() method is finished. So the KN_SCAN
flag could be set only after f_attach() call, but due to both kq and
knlist not locked there, we still have the same race. And this race is
in fact acceptable, since it is the race between application calling
EV_ADD, and external event occuring, which cannot be avoided. Until the
kevent(EV_ADD) syscall returned, we do not have an obligation to report
the event from the kqfd. Having the race somewhat bigger by not setting
KN_SCAN is fine in my opinion.

Received on Thu Apr 03 2014 - 11:48:23 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:48 UTC