| 105 | } |
| 106 | |
| 107 | int |
| 108 | EventNotify::timedwait(int timeout) // milliseconds |
| 109 | { |
| 110 | #if defined(HAVE_EVENTFD) && TS_USE_EPOLL == 1 |
| 111 | ssize_t nr, nr_fd = 0; |
| 112 | uint64_t value = 0; |
| 113 | struct epoll_event ev; |
| 114 | |
| 115 | // |
| 116 | // When timeout < 0, epoll_wait() will wait indefinitely, but |
| 117 | // pthread_cond_timedwait() will return ETIMEDOUT immediately. |
| 118 | // We should keep compatible with pthread_cond_timedwait() here. |
| 119 | // |
| 120 | if (timeout < 0) { |
| 121 | return ETIMEDOUT; |
| 122 | } |
| 123 | |
| 124 | do { |
| 125 | nr_fd = epoll_wait(m_epoll_fd, &ev, 1, timeout); |
| 126 | } while (nr_fd == -1 && errno == EINTR); |
| 127 | |
| 128 | if (nr_fd == 0) { |
| 129 | return ETIMEDOUT; |
| 130 | } else if (nr_fd == -1) { |
| 131 | return errno; |
| 132 | } |
| 133 | |
| 134 | nr = read(m_event_fd, &value, sizeof(uint64_t)); |
| 135 | if (nr == sizeof(uint64_t)) { |
| 136 | return 0; |
| 137 | } else { |
| 138 | return errno; |
| 139 | } |
| 140 | #else |
| 141 | ink_timestruc abstime; |
| 142 | |
| 143 | abstime = ink_hrtime_to_timespec(ink_get_hrtime() + HRTIME_SECONDS(timeout)); |
| 144 | return ink_cond_timedwait(&m_cond, &m_mutex, &abstime); |
| 145 | #endif |
| 146 | } |
| 147 | |
| 148 | void |
| 149 | EventNotify::lock() |
nothing calls this directly
no test coverage detected