How can the nginx detect the stale event using 'instance'?
mdounin at mdounin.ru
Tue Feb 21 13:28:07 UTC 2012
On Tue, Feb 21, 2012 at 06:51:19PM +0900, 김수영 wrote:
> These days, I am studying the nginx source code..
> I think this code is very beautiful, and fully modulized.. BUT so it is difficult to follow the code.-_-;
> BTW, In struct ngx_event_s, there is ‘unsigned instance:1;’..
> I can’t understand how can the nginx detect the stale events using it.-_-;
> Could you please explain the detection mechanism or give me a hint?
The "instance" bit is passed in a event user data to the kernel
and when the kernel returns the event it's checked against one
recorded in the event structure. If there is no match - this
means the event reported by the kernel is stale (i.e. we've
already closed the descriptor in the very same event loop
See e.g. src/event/modules/ngx_kqueue_module.c for details, in
particular ngx_kqueue_set_event() and ngx_kqueue_process_events().
More information about the nginx-devel