| 693 | */ |
| 694 | |
| 695 | void |
| 696 | cupsdRemoveSelect(int fd) /* I - File descriptor */ |
| 697 | { |
| 698 | _cupsd_fd_t *fdptr; /* File descriptor record */ |
| 699 | #ifdef HAVE_EPOLL |
| 700 | struct epoll_event event; /* Event data */ |
| 701 | #elif defined(HAVE_KQUEUE) |
| 702 | struct kevent event; /* Event data */ |
| 703 | struct timespec timeout; /* Timeout value */ |
| 704 | #elif defined(HAVE_POLL) |
| 705 | /* No variables for poll() */ |
| 706 | #endif /* HAVE_EPOLL */ |
| 707 | |
| 708 | |
| 709 | /* |
| 710 | * Range check input... |
| 711 | */ |
| 712 | |
| 713 | cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdRemoveSelect(fd=%d)", fd); |
| 714 | |
| 715 | if (fd < 0) |
| 716 | return; |
| 717 | |
| 718 | /* |
| 719 | * Find the file descriptor... |
| 720 | */ |
| 721 | |
| 722 | if ((fdptr = find_fd(fd)) == NULL) |
| 723 | return; |
| 724 | |
| 725 | #ifdef HAVE_EPOLL |
| 726 | if (epoll_ctl(cupsd_epoll_fd, EPOLL_CTL_DEL, fd, &event)) |
| 727 | { |
| 728 | close(cupsd_epoll_fd); |
| 729 | cupsd_epoll_fd = -1; |
| 730 | cupsd_update_pollfds = 1; |
| 731 | } |
| 732 | |
| 733 | #elif defined(HAVE_KQUEUE) |
| 734 | timeout.tv_sec = 0; |
| 735 | timeout.tv_nsec = 0; |
| 736 | |
| 737 | if (fdptr->read_cb) |
| 738 | { |
| 739 | EV_SET(&event, fd, EVFILT_READ, EV_DELETE, 0, 0, fdptr); |
| 740 | |
| 741 | if (kevent(cupsd_kqueue_fd, &event, 1, NULL, 0, &timeout)) |
| 742 | { |
| 743 | cupsdLogMessage(CUPSD_LOG_EMERG, "kevent() returned %s", |
| 744 | strerror(errno)); |
| 745 | goto cleanup; |
| 746 | } |
| 747 | } |
| 748 | |
| 749 | if (fdptr->write_cb) |
| 750 | { |
| 751 | EV_SET(&event, fd, EVFILT_WRITE, EV_DELETE, 0, 0, fdptr); |
| 752 |
no test coverage detected