mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 14:44:19 -06:00
ENH: CLI: retry pipes no matter which error found
JIRA: no jira Change-Id: Ic49dd1a55e83485eb72b5be97ba9509261f6c133
This commit is contained in:
parent
18d6b60b89
commit
c6af13a612
1 changed files with 7 additions and 12 deletions
|
@ -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]{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue