Permalink
Browse files

Merge pull request #21 from roniegh/960ae8d58e3b94aa8ca897b7efe2340ad…

…c167a86

After calling CancelIo, wait for all IO operations to finish before closing handles and freeing OVERLAPPED structures.
  • Loading branch information...
2 parents 4edee67 + 960ae8d commit ac58f521fdc61d7cd302bade13baab7dcc66b0ce @nyholku committed Mar 23, 2013
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/jtermios/windows/JTermiosImpl.java
View
5 src/jtermios/windows/JTermiosImpl.java
@@ -157,7 +157,12 @@ public void close() {
log = log && log(1, "CancelIo() failed, GetLastError()= %d, %s\n", GetLastError(), lineno(1));
if (!PurgeComm(m_Comm, PURGE_TXABORT + PURGE_TXCLEAR + PURGE_RXABORT + PURGE_RXCLEAR))
log = log && log(1, "PurgeComm() failed, GetLastError()= %d, %s\n", GetLastError(), lineno(1));
+
+ GetOverlappedResult(m_Comm, m_RdOVL, m_RdN, true);
+ GetOverlappedResult(m_Comm, m_WrOVL, m_WrN, true);
+ GetOverlappedResult(m_Comm, m_SelOVL, m_SelN, true);
}
+
HANDLE h; // / 'hEvent' might never have been 'read' so read it
// to this var first

0 comments on commit ac58f52

Please sign in to comment.