ENH: CLI: retry pipes no matter which error found

JIRA: no jira
Change-Id: Ic49dd1a55e83485eb72b5be97ba9509261f6c133
This commit is contained in:
lane.wei 2023-10-11 14:46:11 +08:00 committed by Lane.Wei
parent 18d6b60b89
commit c6af13a612

View file

@ -299,20 +299,15 @@ typedef struct _cli_callback_mgr {
BOOST_LOG_TRIVIAL(info) << "cli_callback_mgr_t::start enter.";
m_pipe_fd = open(pipe_name.c_str(),O_WRONLY|O_NONBLOCK);
while (m_pipe_fd < 0) {
BOOST_LOG_TRIVIAL(warning) << boost::format("could not open pipe for %1%, errno %2%, retry_count = %3%")%pipe_name %errno %retry_count;
if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) {
retry_count ++;
if (retry_count >= 10) {
BOOST_LOG_TRIVIAL(warning) << boost::format("reach max retry_count, failed to open pipe");
return false;
}
boost::this_thread::sleep(boost::posix_time::milliseconds(20));
m_pipe_fd = open(pipe_name.c_str(),O_WRONLY|O_NONBLOCK);
}
else {
BOOST_LOG_TRIVIAL(warning) << boost::format("Failed to open pipe, reason: %1%")%strerror(errno);
if ((retry_count%10) == 0)
BOOST_LOG_TRIVIAL(warning) << boost::format("could not open pipe for %1%, errno %2%, reason: %3%, retry_count = %4%")%pipe_name %errno %strerror(errno) %retry_count;
retry_count ++;
if (retry_count >= 50) {
BOOST_LOG_TRIVIAL(warning) << boost::format("reach max retry_count, failed to open pipe");
return false;
}
boost::this_thread::sleep(boost::posix_time::milliseconds(20));
m_pipe_fd = open(pipe_name.c_str(),O_WRONLY|O_NONBLOCK);
}
std::unique_lock<std::mutex> lck(m_mutex);
m_thread = create_thread([this]{