Mercurial > hg > nginx
diff src/event/ngx_event_accept.c @ 373:018569a8f09c
nginx-0.0.7-2004-06-30-19:30:41 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 30 Jun 2004 15:30:41 +0000 |
parents | 54f76b0b8dca |
children | 213f17e9f776 |
line wrap: on
line diff
--- a/src/event/ngx_event_accept.c +++ b/src/event/ngx_event_accept.c @@ -210,10 +210,31 @@ void ngx_event_accept(ngx_event_t *ev) rinstance = rev->returned_instance; winstance = wev->returned_instance; +#if (NGX_THREADS) + + /* + * We has to acquire the lock to avoid the race condition when + * the connection was just closed by another thread but its lock + * is not unlocked at this point and we got the same descriptor. + * + * The condition should be too rare. + */ + + if (ngx_trylock(&c->lock) == 0) { + + /* TODO: ngx_cycle->stat.accept.spinlock++; */ + + ngx_spinlock(&c->lock, 1000); + } + +#endif + ngx_memzero(rev, sizeof(ngx_event_t)); ngx_memzero(wev, sizeof(ngx_event_t)); ngx_memzero(c, sizeof(ngx_connection_t)); + /* ngx_memzero(c) does ngx_unlock(&c->lock); */ + c->pool = pool; c->listening = ls->listening;