mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-10-04 07:30:52 +00:00
Fix build on non-linux platforms
This commit is contained in:
parent
d277db52fd
commit
f3555ad2d4
@ -11,7 +11,12 @@
|
|||||||
#include <common/logger_useful.h>
|
#include <common/logger_useful.h>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <Common/PipeFDs.h>
|
#include <Common/PipeFDs.h>
|
||||||
#include <sys/epoll.h>
|
|
||||||
|
#ifdef POCO_HAVE_FD_EPOLL
|
||||||
|
#include <sys/epoll.h>
|
||||||
|
#else
|
||||||
|
#include <poll.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
@ -48,8 +53,10 @@ struct SocketInterruptablePollWrapper
|
|||||||
return pipe.fds_rw[1];
|
return pipe.fds_rw[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
PollStatus poll(Poco::Timespan remainingTime)
|
PollStatus poll(Poco::Timespan remaining_time)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if defined(POCO_HAVE_FD_EPOLL)
|
||||||
int epollfd = epoll_create(2);
|
int epollfd = epoll_create(2);
|
||||||
|
|
||||||
if (epollfd < 0)
|
if (epollfd < 0)
|
||||||
@ -77,25 +84,55 @@ struct SocketInterruptablePollWrapper
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
Poco::Timestamp start;
|
Poco::Timestamp start;
|
||||||
rc = epoll_wait(epollfd, &evout, 1, remainingTime.totalMilliseconds());
|
rc = epoll_wait(epollfd, &evout, 1, remaining_time.totalMilliseconds());
|
||||||
if (rc < 0 && errno == EINTR)
|
if (rc < 0 && errno == EINTR)
|
||||||
{
|
{
|
||||||
Poco::Timestamp end;
|
Poco::Timestamp end;
|
||||||
Poco::Timespan waited = end - start;
|
Poco::Timespan waited = end - start;
|
||||||
if (waited < remainingTime)
|
if (waited < remaining_time)
|
||||||
remainingTime -= waited;
|
remaining_time -= waited;
|
||||||
else
|
else
|
||||||
remainingTime = 0;
|
remaining_time = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (rc < 0 && errno == EINTR);
|
while (rc < 0 && errno == EINTR);
|
||||||
|
|
||||||
::close(epollfd);
|
::close(epollfd);
|
||||||
|
int out_fd = evout.data.fd;
|
||||||
|
#else
|
||||||
|
pollfd poll_buf[2];
|
||||||
|
poll_buf[0].fd = sockfd;
|
||||||
|
poll_buf[0].events = POLLIN;
|
||||||
|
poll_buf[1].fd = pipe.fds_rw[0];
|
||||||
|
poll_buf[1].events = POLLIN;
|
||||||
|
|
||||||
|
int rc;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Poco::Timestamp start;
|
||||||
|
rc = ::poll(poll_buf, 2, remaining_time.totalMilliseconds());
|
||||||
|
if (rc < 0 && errno == POCO_EINTR)
|
||||||
|
{
|
||||||
|
Poco::Timestamp end;
|
||||||
|
Poco::Timespan waited = end - start;
|
||||||
|
if (waited < remaining_time)
|
||||||
|
remaining_time -= waited;
|
||||||
|
else
|
||||||
|
remaining_time = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (rc < 0 && errno == POCO_EINTR);
|
||||||
|
int out_fd = -1;
|
||||||
|
if (poll_buf[0].revents & POLLIN)
|
||||||
|
out_fd = sockfd;
|
||||||
|
else if (poll_buf[1].revents & POLLIN)
|
||||||
|
out_fd = pipe.fds_rw[0];
|
||||||
|
#endif
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return PollStatus::ERROR;
|
return PollStatus::ERROR;
|
||||||
else if (rc == 0)
|
else if (rc == 0)
|
||||||
return PollStatus::TIMEOUT;
|
return PollStatus::TIMEOUT;
|
||||||
else if (evout.data.fd == pipe.fds_rw[0])
|
else if (out_fd == pipe.fds_rw[0])
|
||||||
{
|
{
|
||||||
UInt64 bytes;
|
UInt64 bytes;
|
||||||
if (read(pipe.fds_rw[0], &bytes, sizeof(bytes)) < 0)
|
if (read(pipe.fds_rw[0], &bytes, sizeof(bytes)) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user