1.现象描述
o If using an event cache...
If you use an event cache or store all the file descriptors returned from epoll_wait(2), then make sure to provide a way to mark its closure
dynamically (i.e., caused by a previous event's processing). Suppose you receive 100 events from epoll_wait(2), and in event #47 a condition
causes event #13 to be closed. If you remove the structure and close(2) the file descriptor for event #13, then your event cache might still
say there are events waiting for that file descriptor causing confusion.One solution for this is to call, during the processing of event 47, epoll_ctl(EPOLL_CTL_DEL) to delete file descriptor 13 and close(2), then
mark its associated data structure as removed and link it to a cleanup list. If you find another event for file descriptor 13 in your batch
processing, you will discover the file descriptor had been previously removed and there will be no confusion.
假如epoll_wait返回100个event,而在处理#47时,把#13关闭了,即epoll_ctl(EPOLL_CTL_DEL) 。但是之后因某种原因#13又被使用epoll_ctl(EPOLL_CTL_ADD),这样cache中就会出现两个#13事件,当处理到某个具体#13事件时,无法区分是delete的,还是刚刚add的。因此需要特殊处理。
2.nginx如何处理
额。。还没弄清楚。。稍后补充吧