diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2014-05-02 08:59:56 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2014-05-02 08:59:56 (GMT) |
commit | 1e3394cc4fee92acebb7c79a7fb31aba9e1aab54 (patch) | |
tree | 84ad5e5324401e5fb231e9656e4bcecbb3387ae7 /win/tclWinSerial.c | |
parent | 340a361ed19847861c47b986eb8d522c1a6cc700 (diff) | |
parent | 7ea92b545f09208376e9a9f8aa1aac53148f3f65 (diff) | |
download | tcl-1e3394cc4fee92acebb7c79a7fb31aba9e1aab54.zip tcl-1e3394cc4fee92acebb7c79a7fb31aba9e1aab54.tar.gz tcl-1e3394cc4fee92acebb7c79a7fb31aba9e1aab54.tar.bz2 |
merge novemnovem_bug_3598300
Diffstat (limited to 'win/tclWinSerial.c')
-rw-r--r-- | win/tclWinSerial.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/win/tclWinSerial.c b/win/tclWinSerial.c index 2d12fe1..aa16f67 100644 --- a/win/tclWinSerial.c +++ b/win/tclWinSerial.c @@ -1410,23 +1410,22 @@ SerialWriterThread( /* *---------------------------------------------------------------------- * - * TclWinSerialReopen -- + * TclWinSerialOpen -- * - * Reopens the serial port with the OVERLAPPED FLAG set + * Opens or Reopens the serial port with the OVERLAPPED FLAG set * * Results: - * Returns the new handle, or INVALID_HANDLE_VALUE. Normally there - * shouldn't be any error, because the same channel has previously been - * succeesfully opened. + * Returns the new handle, or INVALID_HANDLE_VALUE. + * If an existing channel is specified it is closed and reopened. * * Side effects: - * May close the original handle + * May close/reopen the original handle * *---------------------------------------------------------------------- */ HANDLE -TclWinSerialReopen( +TclWinSerialOpen( HANDLE handle, const TCHAR *name, DWORD access) @@ -1434,16 +1433,22 @@ TclWinSerialReopen( SerialInit(); /* + * If an open channel is specified, close it + */ + + if ( handle != INVALID_HANDLE_VALUE && CloseHandle(handle) == FALSE) { + return INVALID_HANDLE_VALUE; + } + + /* * Multithreaded I/O needs the overlapped flag set otherwise * ClearCommError blocks under Windows NT/2000 until serial output is * finished */ - if (CloseHandle(handle) == FALSE) { - return INVALID_HANDLE_VALUE; - } handle = CreateFile(name, access, 0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); + return handle; } |