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:
Kyle Schwarz
2020-08-14 16:57:52 -04:00
parent afda617894
commit 4cd897badd
6 changed files with 2 additions and 13 deletions
-1
View File
@@ -199,6 +199,5 @@ void FTDI::writeTask() {
continue;
ftdi.write(writeOp.bytes.data(), (int)writeOp.bytes.size());
onWrite();
}
}
-1
View File
@@ -134,6 +134,5 @@ void STM32::writeTask() {
ssize_t actualWritten = ::write(fd, writeOp.bytes.data(), writeSize);
if(actualWritten != writeSize)
report(APIEvent::Type::FailedToWrite, APIEvent::Severity::Error);
onWrite();
}
}
-1
View File
@@ -297,7 +297,6 @@ void PCAP::writeTask() {
auto bs = sendPacket.getBytestream();
if(!closing)
pcap.sendpacket(interface.fp, bs.data(), (int)bs.size());
onWrite();
// TODO Handle packet send errors
}
}
-2
View File
@@ -401,8 +401,6 @@ void VCP::writeTask() {
bytesWritten = 0;
if(WriteFile(handle, writeOp.bytes.data(), (DWORD)writeOp.bytes.size(), nullptr, &overlappedWrite))
continue;
onWrite();
auto winerr = GetLastError();
if(winerr == ERROR_IO_PENDING) {