| 127 | } |
| 128 | |
| 129 | PollResult poll(Poco::Timespan remaining_time, const std::shared_ptr<ReadBufferFromPocoSocket> & in) |
| 130 | { |
| 131 | |
| 132 | bool socket_ready = false; |
| 133 | bool fd_ready = false; |
| 134 | |
| 135 | if (in->available() != 0) |
| 136 | socket_ready = true; |
| 137 | |
| 138 | if (response_in.available() != 0) |
| 139 | fd_ready = true; |
| 140 | |
| 141 | int rc = 0; |
| 142 | if (!fd_ready) |
| 143 | { |
| 144 | #if defined(POCO_HAVE_FD_EPOLL) |
| 145 | epoll_event evout[2]; |
| 146 | evout[0].data.fd = evout[1].data.fd = -1; |
| 147 | do |
| 148 | { |
| 149 | Poco::Timestamp start; |
| 150 | rc = epoll_wait(epollfd, evout, 2, remaining_time.totalMilliseconds()); |
| 151 | if (rc < 0 && errno == EINTR) |
| 152 | { |
| 153 | Poco::Timestamp end; |
| 154 | Poco::Timespan waited = end - start; |
| 155 | if (waited < remaining_time) |
| 156 | remaining_time -= waited; |
| 157 | else |
| 158 | remaining_time = 0; |
| 159 | } |
| 160 | } |
| 161 | while (rc < 0 && errno == EINTR); |
| 162 | |
| 163 | for (int i = 0; i < rc; ++i) |
| 164 | { |
| 165 | if (evout[i].data.fd == sockfd) |
| 166 | socket_ready = true; |
| 167 | if (evout[i].data.fd == pipe.fds_rw[0]) |
| 168 | fd_ready = true; |
| 169 | } |
| 170 | #else |
| 171 | pollfd poll_buf[2]; |
| 172 | poll_buf[0].fd = sockfd; |
| 173 | poll_buf[0].events = POLLIN; |
| 174 | poll_buf[1].fd = pipe.fds_rw[0]; |
| 175 | poll_buf[1].events = POLLIN; |
| 176 | |
| 177 | do |
| 178 | { |
| 179 | Poco::Timestamp start; |
| 180 | rc = ::poll(poll_buf, 2, remaining_time.totalMilliseconds()); |
| 181 | if (rc < 0 && errno == POCO_EINTR) |
| 182 | { |
| 183 | Poco::Timestamp end; |
| 184 | Poco::Timespan waited = end - start; |
| 185 | if (waited < remaining_time) |
| 186 | remaining_time -= waited; |
no test coverage detected