> m_OverlapWrite.hEvent is being closed twice.
>
> CWMProvider::~CWMProvider()
>
> {
>
> if (m_OverlapRead.hEvent != NULL) {
>
> CloseHandle(m_OverlapWrite.hEvent);
This has been fixed.
>
> }
>
> if (m_OverlapWrite.hEvent != NULL) {
>
> CloseHandle(m_OverlapWrite.hEvent);
>
> }
>
>
>
> Writefile is not being used according to the docs. Should be something
> like:
>
>
>
> m_OverlapWrite.Offset = 0;
>
> m_OverlapWrite.OffsetHigh = 0;
>
>
>
> EnterCriticalSection(&m_CritSecWrite);
>
> ret = WriteFile(m_hFile, pMad, bytes,
> &bytes, &m_OverlapWrite);
>
> if (ret==0) {
>
> if(GetLastError() == ERROR_IO_PENDING) {
>
> hr = GetOverlappedResult(&m_OverlapWrite, &bytes, TRUE);
>
> } else {
>
> Print()
>
> hr = ???
>
> }
The current code looks okay to me. From the documentation:
"For an hFile that does not support byte offsets, Offset and OffsetHigh are
ignored."
We can add initialization code to clear the overlap structures, so if we ever
do want to support byte offsets, we'll have that capability. But, it's
technically not needed.
The file itself is always opened using asynchronous operation. A user can
control the WMProvider:Send() operation by passing in NULL for pOverlapped.
NULL results in Send() behaving in synchronously. Otherwise, the default
asynchronous operation is in effect. This accounts for the following code:
if (pOverlapped == NULL) {
// Send() is synchronous
EnterCriticalSection(&m_CritSecWrite);
WriteFile(m_hFile, pMad, bytes, &bytes, &m_OverlapWrite);
hr = GetOverlappedResult(&m_OverlapWrite, &bytes, TRUE);
LeaveCriticalSection(&m_CritSecWrite);
} else {
// Send() is async
if (WriteFile(m_hFile, pMad, bytes, &bytes, pOverlapped)) {
hr = NOERROR;
} else {
hr = HRESULT_FROM_WIN32(GetLastError());
}
}
A user wishing for asynchronous operation must handle Send() returning IO
pending.
- Sean
_______________________________________________
ofw mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/ofw