ENH: Optimization of File Transfer System Part1

jira: [STUDIO-11777]

Change-Id: I733fd3532caa19546763ab8a72eb7667d5ffec53
(cherry picked from commit aa52c99076a78e2c8fd8d4e4b0b64de0bc761469)
This commit is contained in:
milk
2025-04-21 21:00:14 +08:00
committed by Noisyfox
parent 4ef27847cd
commit 7f471d59a5
6 changed files with 124 additions and 34 deletions

View File

@@ -1524,7 +1524,7 @@ void PrinterFileSystem::Reconnect(boost::unique_lock<boost::mutex> &l, int resul
if (m_session.owner == nullptr)
return;
json r;
while (!m_callbacks.empty()) {
while(!m_callbacks.empty()) {
auto c = m_callbacks.front();
m_callbacks.pop_front();
++m_sequence;
@@ -1537,6 +1537,8 @@ void PrinterFileSystem::Reconnect(boost::unique_lock<boost::mutex> &l, int resul
while (m_stopped) {
if (m_session.owner == nullptr)
return;
m_status = Status::Stopped;
SendChangedEvent(EVT_STATUS_CHANGED, m_status);
m_cond.wait(l);
}
wxLogMessage("PrinterFileSystem::Reconnect Initializing");
@@ -1563,6 +1565,7 @@ void PrinterFileSystem::Reconnect(boost::unique_lock<boost::mutex> &l, int resul
Bambu_Tunnel tunnel = nullptr;
int ret = Bambu_Create(&tunnel, url.c_str());
if (ret == 0) {
Bambu_SetLogger(tunnel, DumpLog, this);
ret = Bambu_Open(tunnel);
}
@@ -1571,7 +1574,7 @@ void PrinterFileSystem::Reconnect(boost::unique_lock<boost::mutex> &l, int resul
ret = Bambu_StartStreamEx
? Bambu_StartStreamEx(tunnel, CTRL_TYPE)
: Bambu_StartStream(tunnel, false);
if (ret == Bambu_would_block)
if (ret == Bambu_would_block) {}
boost::this_thread::sleep(boost::posix_time::milliseconds(100));
} while (ret == Bambu_would_block && !m_stopped);
l.lock();
@@ -1591,6 +1594,7 @@ void PrinterFileSystem::Reconnect(boost::unique_lock<boost::mutex> &l, int resul
}
wxLogMessage("PrinterFileSystem::Reconnect Failed");
m_status = Status::Failed;
SendChangedEvent(EVT_STATUS_CHANGED, m_status, "", url.size() < 2 ? 1 : m_last_error);
m_cond.timed_wait(l, boost::posix_time::seconds(10));
}