<div><div>hello!</div><div>These days, I am studying the nginx source code.. </div><div>I think this code is very beautiful.</div><div>But there is a question.</div><div>If there is some coming event : #1, #2,#3 .. #40, ,</div><div>When we deal with #1, #40 will shut down and it's variables instance is 0</div><div>and #2.#3 is a new connection,</div><div>Accept function to allocate a new descriptor which is just free (#40),</div><div>when we deal with #2, </div><div>we need to invoke function named ngx_event_accept, and then invoke ngx_get_connection,</div><div>but unfortunately after that ,we failed which mean we need to free connection,but we have invoked ngx_get_connection once which means variables instance have changed once.</div><div>when we deal with #3,we success, the fd set to 40, and the value of instance is changed again. </div><div>Now it's the same with before, so the  following Judgment statement in the function named ngx_epoll_process_events will not  work,</div><div>if (c->fd == -1 || rev->instance != instance) {</div><div>            /*</div><div>             * the stale event from a file descriptor</div><div>             * that was just closed in this iteration</div><div>             */</div><div>            ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,</div><div>                           "epoll: stale event %p", c);</div><div>            continue;</div><div>}</div><div>I know  it can post event not handle,but if i don't use ngx_use_accept_mutex,which means the flag in function ngx_process_events_and_timers doesn't include NGX_POST_EVENTS,</div><div>in this case,it will not post event but handle event  immediately and it's wrong because #40 is stale event.</div><div><br></div><div>I'm looking forward to your early reply.</div><div>Thank you!</div><div><br></div><div><br></div></div>