| 72 | } |
| 73 | |
| 74 | void UserspaceEventManager::close(int fd) |
| 75 | { |
| 76 | ldout(cct, 20) << __func__ << " fd=" << fd << dendl; |
| 77 | if ((size_t)fd >= fds.size()) |
| 78 | return ; |
| 79 | |
| 80 | std::optional<UserspaceFDImpl> &impl = fds[fd]; |
| 81 | if (!impl) |
| 82 | return ; |
| 83 | |
| 84 | if (fd == max_fd) |
| 85 | --max_fd; |
| 86 | else |
| 87 | unused_fds.push_back(fd); |
| 88 | |
| 89 | if (impl->activating_mask) { |
| 90 | if (waiting_fds[max_wait_idx] == fd) { |
| 91 | ceph_assert(impl->waiting_idx == max_wait_idx); |
| 92 | --max_wait_idx; |
| 93 | } |
| 94 | waiting_fds[impl->waiting_idx] = -1; |
| 95 | } |
| 96 | impl.reset(); |
| 97 | } |
| 98 | |
| 99 | int UserspaceEventManager::poll(int *events, int *masks, int num_events, struct timeval *tp) |
| 100 | { |