> -----Original Message----- > From: Tzachi Dar [mailto:[email protected]] > Sent: Monday, September 06, 2010 3:01 PM > To: Hefty, Sean > Cc: [email protected] > Subject: RE: [PATCH] winmad: check return value of Read/WriteFile > > I believe that there is also a similar issue with DeviceIoControl on > the same file. > > Thanks > Tzachi > > > -----Original Message----- > > From: Hefty, Sean [mailto:[email protected]] > > Sent: Thursday, September 02, 2010 11:00 PM > > To: Hefty, Sean; Tzachi Dar > > Cc: [email protected] > > Subject: [PATCH] winmad: check return value of Read/WriteFile > > > > When performing synchronous operation, we need to check the return > > value of ReadFile/WriteFile before calling GetOverlappedResult. > > Otherwise GetOverlappedResult can hang. > > > > Signed-off-by: Sean Hefty <[email protected]> > > --- > > > > Index: trunk/core/winmad/user/wm_provider.cpp > > =================================================================== > > --- trunk/core/winmad/user/wm_provider.cpp (revision 2893) > > +++ trunk/core/winmad/user/wm_provider.cpp (working copy) > > @@ -187,8 +187,11 @@ > > bytes = (DWORD) sizeof(WM_MAD) + pMad->Length; > > if (pOverlapped == NULL) { > > EnterCriticalSection(&m_CritSecWrite); > > - WriteFile(m_hFile, pMad, bytes, &bytes, &m_OverlapWrite); > > - hr = GetOverlappedResult(&m_OverlapWrite, &bytes, TRUE); > > + if (WriteFile(m_hFile, pMad, bytes, &bytes, > > &m_OverlapWrite)) { > > + hr = GetOverlappedResult(&m_OverlapWrite, &bytes, > > TRUE); > > + } else { > > + hr = HRESULT_FROM_WIN32(GetLastError()); > > + } > > LeaveCriticalSection(&m_CritSecWrite); > > } else { > > if (WriteFile(m_hFile, pMad, bytes, &bytes, pOverlapped)) { > > @@ -209,8 +212,11 @@ > > > > if (pOverlapped == NULL) { > > EnterCriticalSection(&m_CritSecRead); > > - ReadFile(m_hFile, pMad, (DWORD) BufferSize, &bytes, > > &m_OverlapRead); > > - hr = GetOverlappedResult(&m_OverlapRead, &bytes, TRUE); > > + if (ReadFile(m_hFile, pMad, (DWORD) BufferSize, &bytes, > > &m_OverlapRead)) { > > + hr = GetOverlappedResult(&m_OverlapRead, &bytes, > > TRUE); > > + } else { > > + hr = HRESULT_FROM_WIN32(GetLastError()); > > + } > > LeaveCriticalSection(&m_CritSecRead); > > } else { > > if (ReadFile(m_hFile, pMad, (DWORD) BufferSize, &bytes, > > pOverlapped)) {
_______________________________________________ ofw mailing list [email protected] http://lists.openfabrics.org/cgi-bin/mailman/listinfo/ofw
