[Com0com-cvs] hub4com/plugins/tcp comio.cpp,1.2,1.3
The virtual serial port driver for Windows.
Brought to you by:
vfrolov
From: Vyacheslav F. <vf...@us...> - 2008-10-06 12:13:15
|
Update of /cvsroot/com0com/hub4com/plugins/tcp In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4215 Modified Files: comio.cpp Log Message: Duplicated code moved to SetThread() Index: comio.cpp =================================================================== RCS file: /cvsroot/com0com/hub4com/plugins/tcp/comio.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** comio.cpp 26 Aug 2008 14:07:01 -0000 1.2 --- comio.cpp 6 Oct 2008 12:12:29 -0000 1.3 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.3 2008/10/06 12:12:29 vfrolov + * Duplicated code moved to SetThread() + * * Revision 1.2 2008/08/26 14:07:01 vfrolov * Execute OnEvent() in main thread context *************** *** 272,280 **** static DWORD idThread; #endif /* _DEBUG */ ! /////////////////////////////////////////////////////////////// ! WaitEventOverlapped::WaitEventOverlapped(ComPort &_port, SOCKET hSockWait) ! : port(_port), ! hSock(hSockWait), ! hWait(INVALID_HANDLE_VALUE) { #ifdef _DEBUG --- 275,280 ---- static DWORD idThread; #endif /* _DEBUG */ ! ! static BOOL SetThread() { #ifdef _DEBUG *************** *** 299,309 **** TraceError( GetLastError(), ! "WaitEventOverlapped::WaitEventOverlapped(): DuplicateHandle() %s", ! port.Name().c_str()); ! return; } } hEvent = ::CreateEvent(NULL, FALSE, FALSE, NULL); --- 299,319 ---- TraceError( GetLastError(), ! "SetThread(): DuplicateHandle()"); ! return FALSE; } } + return TRUE; + } + /////////////////////////////////////////////////////////////// + WaitEventOverlapped::WaitEventOverlapped(ComPort &_port, SOCKET hSockWait) + : port(_port), + hSock(hSockWait), + hWait(INVALID_HANDLE_VALUE) + { + if (!SetThread()) + return; + hEvent = ::CreateEvent(NULL, FALSE, FALSE, NULL); *************** *** 426,455 **** hWait(INVALID_HANDLE_VALUE) { ! #ifdef _DEBUG ! if (hThread == INVALID_HANDLE_VALUE) { ! idThread = ::GetCurrentThreadId(); ! } else { ! _ASSERTE(idThread == ::GetCurrentThreadId()); ! } ! #endif /* _DEBUG */ ! ! if (hThread == INVALID_HANDLE_VALUE) { ! if (!::DuplicateHandle(::GetCurrentProcess(), ! ::GetCurrentThread(), ! ::GetCurrentProcess(), ! &hThread, ! 0, ! FALSE, ! DUPLICATE_SAME_ACCESS)) ! { ! hThread = INVALID_HANDLE_VALUE; ! ! TraceError( ! GetLastError(), ! "ListenOverlapped::ListenOverlapped(): DuplicateHandle()"); ! return; - } - } hEvent = ::CreateEvent(NULL, FALSE, FALSE, NULL); --- 436,441 ---- hWait(INVALID_HANDLE_VALUE) { ! if (!SetThread()) return; hEvent = ::CreateEvent(NULL, FALSE, FALSE, NULL); |