Deleted Added
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

--- 532 unchanged lines hidden (view full) ---

541 continue;
542 }
543
544 fd = pfd->fd;
545
546 phe = nxt_poll_fd_hash_get(engine, fd);
547
548 if (nxt_slow_path(phe == NULL)) {
549 nxt_alert(&engine->task,
550 "poll() returned invalid fd:%d ev:%04Xd rev:%04uXi",
551 fd, pfd->events, events);
552
553 /* Mark the poll entry to ignore it by the kernel. */
554 pfd->fd = -1;
555 goto next;
556 }
557
558 ev = phe->event;
559
560 nxt_debug(ev->task, "poll: fd:%d ev:%04uXi rd:%d wr:%d",
561 fd, events, ev->read, ev->write);
562
563 if (nxt_slow_path((events & POLLNVAL) != 0)) {
564 nxt_alert(ev->task, "poll() error fd:%d ev:%04Xd rev:%04uXi",
565 fd, pfd->events, events);
566
567 /* Mark the poll entry to ignore it by the kernel. */
568 pfd->fd = -1;
569
570 nxt_work_queue_add(&engine->fast_work_queue,
571 ev->error_handler, ev->task, ev, ev->data);
572 goto next;
573 }

--- 69 unchanged lines hidden (view full) ---

643 lhq.proto = &nxt_poll_fd_hash_proto;
644 lhq.data = engine;
645
646 if (nxt_lvlhsh_find(&engine->u.poll.fd_hash, &lhq) == NXT_OK) {
647 phe = lhq.value;
648 return phe;
649 }
650
651 nxt_alert(&engine->task, "fd %d not found in hash", fd);
652
653 return NULL;
654}
655
656
657static nxt_int_t
658nxt_poll_fd_hash_test(nxt_lvlhsh_query_t *lhq, void *data)
659{

--- 5 unchanged lines hidden (view full) ---

665 /* nxt_murmur_hash2() is unique for 4 bytes. */
666
667 engine = lhq->data;
668
669 if (nxt_fast_path(phe->fd == engine->u.poll.set[phe->index].fd)) {
670 return NXT_OK;
671 }
672
673 nxt_alert(&engine->task, "fd %d in hash mismatches fd %d in poll set",
674 phe->fd, engine->u.poll.set[phe->index].fd);
675
676 return NXT_DECLINED;
677}
678
679
680static void
681nxt_poll_fd_hash_destroy(nxt_event_engine_t *engine, nxt_lvlhsh_t *lh)
682{

--- 10 unchanged lines hidden (view full) ---

693
694 if (phe == NULL) {
695 return;
696 }
697
698 lhq.key_hash = nxt_murmur_hash2(&phe->fd, sizeof(nxt_fd_t));
699
700 if (nxt_lvlhsh_delete(lh, &lhq) != NXT_OK) {
701 nxt_alert(&engine->task, "event fd %d not found in hash", phe->fd);
702 }
703
704 nxt_free(phe);
705 }
706}