mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Allow threads to reopen after closing
This commit is contained in:
@@ -228,6 +228,7 @@ bool PCAP::close() {
|
||||
closing = true; // Signal the threads that we are closing
|
||||
readThread.join();
|
||||
writeThread.join();
|
||||
closing = false;
|
||||
|
||||
pcap.close(interface.fp);
|
||||
interface.fp = nullptr;
|
||||
|
||||
@@ -214,6 +214,7 @@ bool VCP::close() {
|
||||
t->join(); // Wait for the threads to close
|
||||
readThread.join();
|
||||
writeThread.join();
|
||||
closing = false;
|
||||
|
||||
if(!CloseHandle(handle))
|
||||
return false;
|
||||
@@ -224,14 +225,17 @@ bool VCP::close() {
|
||||
if(overlappedRead.hEvent != INVALID_HANDLE_VALUE) {
|
||||
if(!CloseHandle(overlappedRead.hEvent))
|
||||
ret = false;
|
||||
overlappedRead.hEvent = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
if(overlappedWrite.hEvent != INVALID_HANDLE_VALUE) {
|
||||
if(!CloseHandle(overlappedWrite.hEvent))
|
||||
ret = false;
|
||||
overlappedWrite.hEvent = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
if(overlappedWait.hEvent != INVALID_HANDLE_VALUE) {
|
||||
if(!CloseHandle(overlappedWait.hEvent))
|
||||
ret = false;
|
||||
overlappedWait.hEvent = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
// TODO Set up some sort of shared memory, free which COM port we had open so we can try to open it again
|
||||
|
||||
Reference in New Issue
Block a user