comparison src/event/modules/ngx_kqueue_module.c @ 375:744ccb59062d

nginx-0.0.7-2004-07-02-19:54:34 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 02 Jul 2004 15:54:34 +0000
parents 213f17e9f776
children d0451e402e27
comparison
equal deleted inserted replaced
374:213f17e9f776 375:744ccb59062d
235 ngx_event_t *e; 235 ngx_event_t *e;
236 236
237 ev->active = 0; 237 ev->active = 0;
238 ev->disabled = 0; 238 ev->disabled = 0;
239 239
240 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
241 return NGX_ERROR;
242 }
243 ev->posted = 0;
244 ngx_mutex_unlock(ngx_posted_events_mutex);
245
246 if (ngx_thread_main() 240 if (ngx_thread_main()
247 && nchanges > 0 241 && nchanges > 0
248 && ev->index < (u_int) nchanges 242 && ev->index < (u_int) nchanges
249 && ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1) 243 && ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1)
250 == (uintptr_t) ev) 244 == (uintptr_t) ev)
510 case EVFILT_WRITE: 504 case EVFILT_WRITE:
511 505
512 instance = (uintptr_t) ev & 1; 506 instance = (uintptr_t) ev & 1;
513 ev = (ngx_event_t *) ((uintptr_t) ev & (uintptr_t) ~1); 507 ev = (ngx_event_t *) ((uintptr_t) ev & (uintptr_t) ~1);
514 508
515 if (!ev->active || ev->instance != instance) { 509 if (ev->closed || ev->instance != instance) {
516 510
517 /* 511 /*
518 * the stale event from a file descriptor 512 * the stale event from a file descriptor
519 * that was just closed in this iteration 513 * that was just closed in this iteration
520 */ 514 */
528 ngx_kqueue_dump_event(ev->log, &event_list[i]); 522 ngx_kqueue_dump_event(ev->log, &event_list[i]);
529 } 523 }
530 524
531 ev->returned_instance = instance; 525 ev->returned_instance = instance;
532 526
533 if (!ev->accept && (ngx_threaded || ngx_accept_mutex_held)) { 527 #if (NGX_THREADS)
528
529 if (ngx_threaded && !ev->accept) {
534 ev->posted_ready = 1; 530 ev->posted_ready = 1;
535 ev->posted_available += event_list[i].data; 531 ev->posted_available += event_list[i].data;
536 532
537 if (event_list[i].flags & EV_EOF) { 533 if (event_list[i].flags & EV_EOF) {
538 ev->posted_eof = 1; 534 ev->posted_eof = 1;
542 ngx_post_event(ev); 538 ngx_post_event(ev);
543 539
544 continue; 540 continue;
545 } 541 }
546 542
543 #endif
544
547 ev->available = event_list[i].data; 545 ev->available = event_list[i].data;
548 546
549 if (event_list[i].flags & EV_EOF) { 547 if (event_list[i].flags & EV_EOF) {
550 ev->kq_eof = 1; 548 ev->pending_eof = 1;
551 ev->kq_errno = event_list[i].fflags; 549 ev->kq_errno = event_list[i].fflags;
552 } 550 }
553 551
554 ev->ready = 1; 552 ev->ready = 1;
555 553
576 if (!ngx_threaded && !ngx_accept_mutex_held) { 574 if (!ngx_threaded && !ngx_accept_mutex_held) {
577 ev->event_handler(ev); 575 ev->event_handler(ev);
578 continue; 576 continue;
579 } 577 }
580 578
581 #if 0
582 if (!ev->accept) { 579 if (!ev->accept) {
583 ngx_post_event(ev); 580 ngx_post_event(ev);
584 continue; 581 continue;
585 } 582 }
586 #endif
587 583
588 if (ngx_accept_disabled > 0) { 584 if (ngx_accept_disabled > 0) {
589 continue; 585 continue;
590 } 586 }
591 587