mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Fix deadlock with Driver::write
Use a spin lock to recheck the queue size until it has room to push.
This commit is contained in:
@@ -45,9 +45,9 @@ bool Driver::write(const std::vector<uint8_t>& bytes) {
|
||||
}
|
||||
|
||||
if(writeBlocks) {
|
||||
std::unique_lock<std::mutex> lk(writeMutex);
|
||||
if(writeQueue.size_approx() > writeQueueSize)
|
||||
writeCV.wait(lk);
|
||||
while(writeQueue.size_approx() > (writeQueueSize * 3 / 4))
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
} else {
|
||||
if(writeQueue.size_approx() > writeQueueSize) {
|
||||
report(APIEvent::Type::TransmitBufferFull, APIEvent::Severity::Error);
|
||||
|
||||
Reference in New Issue
Block a user