how to handle stale event in nginx -


these days, studying nginx source code.

but there question stale event. if there coming event : #1, #2,#3 .. #40, when deal #1, #40 shut down , it's variables instance 0 , #2.#3 new connection, accept function allocate new descriptor free (#40), when deal #2, need invoke function named ngx_event_accept, , invoke ngx_get_connection, unfortunately after ,we failed mean need free connection,but have invoked ngx_get_connection once means variables instance have changed once. following code (success , failed )

void ngx_event_accept(ngx_event_t *ev) {     ...      /* success */     c = ngx_get_connection(s, ev->log);      if (c == null) {         if (ngx_close_socket(s) == -1) {             ngx_log_error(ngx_log_alert, ev->log, ngx_socket_errno,                           ngx_close_socket_n " failed");         }          return;     }      c->type = sock_stream;     ...    /* failed */     c->pool = ngx_create_pool(ls->pool_size, ev->log);     if (c->pool == null) {         ngx_close_accepted_connection(c);         return;     }      c->sockaddr = ngx_palloc(c->pool, socklen);     if (c->sockaddr == null) {         ngx_close_accepted_connection(c);         return;     }      ngx_memcpy(c->sockaddr, sa, socklen);     /*  or failed here */     log = ngx_palloc(c->pool, sizeof(ngx_log_t));     if (log == null) {         ngx_close_accepted_connection(c);         return;     }     .... } 

when deal #3,we success, fd set 40, , value of instance changed again. it's same before, following judgment statement in function named ngx_epoll_process_events not work,

if (c->fd == -1 || rev->instance != instance) {             /*              * stale event file descriptor              * closed in iteration              */             ngx_log_debug1(ngx_log_debug_event, cycle->log, 0,                            "epoll: stale event %p", c);             continue; } 

i know can post event put in in queue not handle,but if don't use ngx_use_accept_mutex,which means flag in function ngx_process_events_and_timers doesn't include ngx_post_events, in case,it not post event handle event , it's wrong because #40 stale event.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -