Skip to content

Commit f62dfa9

Browse files
committed
Fix not counting unacked messages.
1 parent 3a56d8b commit f62dfa9

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

SerialPrograms/Source/Controllers/PABotBase2/PABotBase2_DeviceHandle.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,23 @@ DeviceHandle::~DeviceHandle(){
4646
"DeviceHandle::~DeviceHandle(): Waiting for " + std::to_string(m_pending_requests.size()) + " request(s) to finish."
4747
);
4848
}catch (...){}
49-
bool ok = m_cv.wait_for(
49+
size_t unacked = 0;
50+
m_cv.wait_for(
5051
lg, std::chrono::milliseconds(100),
51-
[this]{
52-
return m_pending_requests.empty();
52+
[&, this]{
53+
unacked = 0;
54+
for (const auto& item : m_pending_requests){
55+
if (item.second.empty()){
56+
unacked++;
57+
}
58+
}
59+
return unacked == 0;
5360
}
5461
);
55-
if (!ok){
62+
if (unacked != 0){
5663
try{
5764
m_logger.log(
58-
"DeviceHandle::~DeviceHandle(): Timed out waiting for " + std::to_string(m_pending_requests.size()) + " request(s) to finish.",
65+
"DeviceHandle::~DeviceHandle(): Timed out waiting for " + std::to_string(unacked) + " request(s) to finish.",
5966
COLOR_RED
6067
);
6168
}catch (...){}

0 commit comments

Comments
 (0)