FIX: PrinterFileSystem: lost callback when connection not ready
Change-Id: Id0f0c41e51fef8220bd6bd7fb40876840fee05ad Jira: STUDIO-4811
This commit is contained in:
parent
6292df5aa1
commit
0f7dd9b3a4
|
@ -1038,8 +1038,11 @@ void PrinterFileSystem::DumpLog(void * thiz, int, tchar const *msg)
|
||||||
boost::uint32_t PrinterFileSystem::SendRequest(int type, json const &req, callback_t2 const &callback)
|
boost::uint32_t PrinterFileSystem::SendRequest(int type, json const &req, callback_t2 const &callback)
|
||||||
{
|
{
|
||||||
if (m_session.tunnel == nullptr) {
|
if (m_session.tunnel == nullptr) {
|
||||||
boost::unique_lock l(m_mutex);
|
{
|
||||||
m_cond.notify_all();
|
boost::unique_lock l(m_mutex);
|
||||||
|
m_cond.notify_all();
|
||||||
|
}
|
||||||
|
callback(ERROR_PIPE, json(), nullptr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
boost::uint32_t seq = m_sequence + m_callbacks.size();
|
boost::uint32_t seq = m_sequence + m_callbacks.size();
|
||||||
|
@ -1085,23 +1088,28 @@ void PrinterFileSystem::CancelRequests(std::vector<boost::uint32_t> const &seqs)
|
||||||
|
|
||||||
void PrinterFileSystem::CancelRequests2(std::vector<boost::uint32_t> const &seqs)
|
void PrinterFileSystem::CancelRequests2(std::vector<boost::uint32_t> const &seqs)
|
||||||
{
|
{
|
||||||
std::deque<callback_t2> callbacks;
|
std::vector<std::pair<boost::uint32_t, callback_t2>> callbacks;
|
||||||
boost::unique_lock l(m_mutex);
|
boost::unique_lock l(m_mutex);
|
||||||
for (auto &f : seqs) {
|
for (auto &f : seqs) {
|
||||||
boost::uint32_t seq = f;
|
boost::uint32_t seq = f;
|
||||||
seq -= m_sequence;
|
seq -= m_sequence;
|
||||||
if (size_t(seq) >= m_callbacks.size()) continue;
|
if (size_t(seq) >= m_callbacks.size())
|
||||||
|
continue;
|
||||||
auto &c = m_callbacks[seq];
|
auto &c = m_callbacks[seq];
|
||||||
if (c == nullptr) continue;
|
if (c == nullptr)
|
||||||
callbacks.push_back(c);
|
continue;
|
||||||
m_callbacks[seq] = callback_t2();
|
callbacks.emplace_back(f, c);
|
||||||
|
c = nullptr;
|
||||||
}
|
}
|
||||||
while (!m_callbacks.empty() && m_callbacks.front() == nullptr) {
|
while (!m_callbacks.empty() && m_callbacks.front() == nullptr) {
|
||||||
m_callbacks.pop_front();
|
m_callbacks.pop_front();
|
||||||
++m_sequence;
|
++m_sequence;
|
||||||
}
|
}
|
||||||
l.unlock();
|
l.unlock();
|
||||||
for (auto &c : callbacks) c(ERROR_CANCEL, json(), nullptr);
|
for (auto &c : callbacks) {
|
||||||
|
wxLogInfo("PrinterFileSystem::CancelRequests2: %u\n", c.first);
|
||||||
|
c.second(ERROR_CANCEL, json(), nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrinterFileSystem::RecvMessageThread()
|
void PrinterFileSystem::RecvMessageThread()
|
||||||
|
|
Loading…
Reference in New Issue