From c6af13a6123b86c0d907d7b9eceff18b82b2351c Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Wed, 11 Oct 2023 14:46:11 +0800 Subject: [PATCH] ENH: CLI: retry pipes no matter which error found JIRA: no jira Change-Id: Ic49dd1a55e83485eb72b5be97ba9509261f6c133 --- src/BambuStudio.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/BambuStudio.cpp b/src/BambuStudio.cpp index 16b8494cb6..28787a0dfc 100644 --- a/src/BambuStudio.cpp +++ b/src/BambuStudio.cpp @@ -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 lck(m_mutex); m_thread = create_thread([this]{