comparison 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
comparison
equal deleted inserted replaced
372:c9fdfccebc49 373:018569a8f09c
208 208
209 instance = rev->instance; 209 instance = rev->instance;
210 rinstance = rev->returned_instance; 210 rinstance = rev->returned_instance;
211 winstance = wev->returned_instance; 211 winstance = wev->returned_instance;
212 212
213 #if (NGX_THREADS)
214
215 /*
216 * We has to acquire the lock to avoid the race condition when
217 * the connection was just closed by another thread but its lock
218 * is not unlocked at this point and we got the same descriptor.
219 *
220 * The condition should be too rare.
221 */
222
223 if (ngx_trylock(&c->lock) == 0) {
224
225 /* TODO: ngx_cycle->stat.accept.spinlock++; */
226
227 ngx_spinlock(&c->lock, 1000);
228 }
229
230 #endif
231
213 ngx_memzero(rev, sizeof(ngx_event_t)); 232 ngx_memzero(rev, sizeof(ngx_event_t));
214 ngx_memzero(wev, sizeof(ngx_event_t)); 233 ngx_memzero(wev, sizeof(ngx_event_t));
215 ngx_memzero(c, sizeof(ngx_connection_t)); 234 ngx_memzero(c, sizeof(ngx_connection_t));
235
236 /* ngx_memzero(c) does ngx_unlock(&c->lock); */
216 237
217 c->pool = pool; 238 c->pool = pool;
218 239
219 c->listening = ls->listening; 240 c->listening = ls->listening;
220 c->sockaddr = sa; 241 c->sockaddr = sa;