mirror of
https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git
synced 2026-11-25 18:37:19 +00:00
fix: close windows read handle when reading one byte (#197)
Makes sure we always close the event handle when we're done reading. Finishes up #165
This commit is contained in:
parent
f8bfc1eed2
commit
4655cc1439
1 changed files with 3 additions and 1 deletions
|
|
@ -455,6 +455,7 @@ void __stdcall ReadIOCompletion(DWORD errorCode, DWORD bytesTransferred, OVERLAP
|
|||
}
|
||||
if (!baton->bytesToRead) {
|
||||
baton->complete = true;
|
||||
CloseHandle(ov->hEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -467,6 +468,7 @@ void __stdcall ReadIOCompletion(DWORD errorCode, DWORD bytesTransferred, OVERLAP
|
|||
lastError = GetLastError();
|
||||
ErrorCodeToString("Setting COM timeout (SetCommTimeouts)", lastError, baton->errorString);
|
||||
baton->complete = true;
|
||||
// CloseHandle(ov->hEvent); // wondering if we need to close the handle here
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -494,11 +496,11 @@ void __stdcall ReadIOCompletion(DWORD errorCode, DWORD bytesTransferred, OVERLAP
|
|||
return;
|
||||
}
|
||||
}
|
||||
CloseHandle(ov->hEvent);
|
||||
|
||||
baton->bytesToRead -= bytesTransferred;
|
||||
baton->bytesRead += bytesTransferred;
|
||||
baton->complete = true;
|
||||
CloseHandle(ov->hEvent);
|
||||
}
|
||||
|
||||
DWORD __stdcall ReadThread(LPVOID param) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue