Improve logging messages for POLLHUP and POLLERR conditions

Don't report EINTR from poll
This commit is contained in:
Aleksei Nikiforov 2020-01-14 15:25:27 +03:00
parent 6677b661c2
commit ddcdfa9c1c

View File

@ -462,10 +462,13 @@ void writer_thread_function(clickhouse::Client &client, const std::string &table
if (res < 0)
{
// error occured, finish running
Logger::write("Poll returned error: %d\n", errno);
stop_running();
thread_keep_running = false;
if (errno != EINTR)
{
// error occured, finish running
Logger::write("Poll returned error: %d\n", errno);
stop_running();
thread_keep_running = false;
}
}
else if (res == 0)
{
@ -480,7 +483,7 @@ void writer_thread_function(clickhouse::Client &client, const std::string &table
else if ((pollfds[0].revents & POLLHUP) || (pollfds[0].revents & POLLERR))
{
// pipe closed too early, an error
Logger::write("Read returned error: %d\n", errno);
Logger::write("Read returned pollhup or pollerr\n");
stop_running();
thread_keep_running = false;
}
@ -498,7 +501,7 @@ void writer_thread_function(clickhouse::Client &client, const std::string &table
else if ((pollfds[1].revents & POLLHUP) || (pollfds[1].revents & POLLERR))
{
// pipe closed too early, an error
Logger::write("Read returned error: %d\n", errno);
Logger::write("Read returned pollhup or pollerr\n");
stop_running();
thread_keep_running = false;
}
@ -981,9 +984,12 @@ int main(int argc, char **argv)
int res = poll(pollfds, sizeof(pollfds) / sizeof(pollfds[0]), -1);
if (res < 0)
{
// error occured, finish running
Logger::write("Poll returned error: %d\n", errno);
running = false;
if (errno != EINTR)
{
// error occured, finish running
Logger::write("Poll returned error: %d\n", errno);
running = false;
}
}
else if (res == 0)
{